The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

Advanced Search

Back to Topic List Back to Topic List  

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


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

Any help appriciated!

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.