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

조회 수: 3 (최근 30일)
dvd7e
dvd7e 2018년 5월 25일
댓글: dvd7e 2018년 5월 25일
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
TAB
TAB 2018년 5월 25일
Can you share part of your code ?
dvd7e
dvd7e 2018년 5월 25일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by