Borrar filtros
Borrar filtros

Why can't I see instantiated objects with the Simulink debugger?

2 visualizaciones (últimos 30 días)
dvd7e
dvd7e el 25 de Mayo de 2018
Comentada: dvd7e el 25 de Mayo de 2018
I have some embedded matlab code inside a Simulink simulation and I'm instantiating some objects. When I step through with the debugger and set a breakpoint in the embedded matlab, I can see all the other local variables (as expected) but I cannot see the object or do anything with it that I normally could when stepping through with the Matlab debugger (outside of Simulink). The code does still run, I just can't see it in the debugger.
Any idea why? Is there a way around this?
Thanks
  2 comentarios
TAB
TAB el 25 de Mayo de 2018
Can you share part of your code ?
dvd7e
dvd7e el 25 de Mayo de 2018
Sure. As a simplified/dummy model, my Simulink is just a Matlab function, with the following code:
function y = fcn()
% Create the car object at simulation startup
persistent bmw
if isempty(bmw)
bmw = car('bmw'); % Instantiate the car object
end
% Every time step move the car's position
bmw.move(1);
% Output the current car position
y = bmw.pos;
and this is the class definition for a "car":
classdef car < handle
properties
name = '';
m = 1000;
pos = 0;
end
methods
function obj = car(nameIn)
obj.name = nameIn;
end
function obj = move(obj,stepVal)
obj.pos = obj.pos + stepVal;
end
function obj = resetPos(obj)
obj.pos = 0;
end
end
end
When I run this in Simulink it behaves as expected. Every iteration it moves the car position by 1 and outputs that position. The issue I'm seeing is that when I use the debugger to step through and put a breakpoint in the embedded matlab, I can't see the car object or any of its methods or properties. I usually can do this with the Matlab debugger, but apparently not in Simulink. On the other hand, I can see "normal" variables in the debugger, like the output "y".
Without being able to interact with the objects from the debugger/command line, it makes it much harder to debug or investigate what's going on.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by