MATLAB Answers

0

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)?

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.

Products


Release

R14SP2

2 Answers

Answer by MathWorks Support Team on 8 Jan 2010
 Accepted Answer

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.

  2 Comments

I bought the version R2014a, plus the simpowersim and simhydraulics libraries, now I cannot write the axis time in seconds, what a stupid software this is, that does not have a direct way to label axis like excel graphs for example, piece of sheet software

Sign in to comment.