Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Save a variable to file out of embedded Matlab function?
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Thomas

Posts: 1
Registered: 5/27/13
Save a variable to file out of embedded Matlab function?
Posted: May 27, 2013 5:48 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,

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

Any help appriciated!



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.