accessing workspace variables in embedded matlab function
4 views (last 30 days)
Show older comments
I have a very large model that has numerous busses with lots of data. I enabled data logging on several busses and wrote a matlab function to post process the data logged in the workspace variable 'logsout'. However, I cannot log the data for the full simulation because I run out of memory. Therefore, I would like to run my post processing periodically on the 'logsout' workspace variable then clear the variable and and continue. I was hoping this would allow the simulation to complete without running out of memory.
However, I cannot seem to access the logsout variable in an embedded matlab function. Any suggestions?
0 Comments
Answers (3)
Kaustubha Govind
on 21 Feb 2012
I'm not sure that it is safe to clear the 'logsout' variable during simulation, because the model might have it locked down. Additionally, I imagine that the model writes to an intermediate buffer and only populates the workspace at periodic intervals when the buffer gets full, so there is no guarantee that at time 't', all the data points corresponding to simulation from 0 to 't' have been logged to the workspace.
Have you considered instead saving and restoring the simulation state, so that you can break down your simulation time into short intervals, so that you can work on the 'logsout' piecemeal?
0 Comments
timothy shands
on 21 Feb 2012
1 Comment
Kaustubha Govind
on 22 Feb 2012
1) Yes, you would need to repeat your simulation 100 times, for 19 seconds each time, by restoring the previous simulation state each time. For how - refer to the documentation link I pointed to in my original answer.
2) Are you using a non-virtual bus (should have a Simulink.Bus object corresponding to your signal)? Virtual buses are not supported as inputs to the Embedded MATLAB Function block. Also, if you are using non-virtual bus inputs, you need to configure the block input port accordingly. See http://www.mathworks.com/help/toolbox/simulink/ug/bq156zx.html
See Also
Categories
Find more on Prepare Model Inputs and Outputs in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!