i've spent an hour to find a solution to this, but haven't been successful so far.
I have a persistant variable (a structure) inside an embedded Matlab function in Simulink. At certain intervals (about every thousand steps, but its depending on the simulation) I want to save the variable to my Workspace to later view and compare it.
The "save" function is not allowed in embedded Matlab functions. If I use an Output and a "to workspace" object, it generates a new Matrix each timestep, which would greatly affect performance (its a large four-dimensional Matrix, it needs to be saved about 900 times out of about ~9 million simulation steps).
Is there any way to directly export the variable to a mat file? Like this:
function ... persistant a persitant count A = really large matrix count = count + 1 if count = 500 save(A) to workspace end end