accessing workspace variables in embedded matlab function
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
Kaustubha Govind
2012-2-21
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 个评论
timothy shands
2012-2-21
1 个评论
Kaustubha Govind
2012-2-22
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Prepare Model Inputs and Outputs 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!