MATLAB: How to debug an embedded MATLAB function on a given simulation step in Simulink 6.6 (R2007a)

simulink

How can I debug an embedded MATLAB function on a given simulation step?

Best Answer

The ability to debug an embedded MATLAB function on a given simulation step is not available in SIMULINK.
To work around this issue, use the 'Clock' block and a 'Compare to Constant' block to check if the simulation time reaches a particular value. Feed the result of the compare to an extra input called debug in the EML block. At the start of the EML function, prepend the following:
if (debug == 1)
tempvar = 1;
end
Next, put the breakpoint on the line "tempvar = 1". The breakpoint will only be hit when the simulation time reaches that particular value.