How can I get the data from my To Workspace block into the MATLAB workspace when using the SIM command in a MATLAB function in Simulink 6.2 (R14SP2)?
4 次查看(过去 30 天)
显示 更早的评论
I simulate my Simulink model using the SIM command from a MATLAB function or a GUI created using GUIDE. The To Workspace block in the model does not send the data out to the workspace. If I run the same model from Simulink, the command-line or from a MATLAB script, the To Workspace block does return data to the MATLAB workspace.
采纳的回答
MathWorks Support Team
2010-1-8
This enhancement has been incorporated in Release 2009b (R2009b). For previous product releases, read below for any possible workarounds:
The SIM command simulates the model in the caller workspace that is any output from the model is sent to the caller workspace and not to the base workspace. To work around this you can use the EVALIN command in your MATLAB function or GUI callback where the SIM command is being called.
1. Download the attached files and execute the following code at MATLAB command prompt:
mini_gui
2. Click on the "simulate model" button in the GUI displayed. Verify that "simout" exists in the MATLAB base workspace by typing the following at MATLAB command prompt:
whos
The "mini_gui.m" file uses the following code to import the data to MATLAB base workspace.
evalin('base','sim(''mini_model'')')
Also, note that the SIM command takes the values required for simulation from the base workspace. Refer to the Related Solution below for an example that demonstrates this.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Environment Customization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!