Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How do I plot Simulink signal values saved to the MATLAB workspace on an axes?

Asked by andoni on 31 May 2011
Latest activity Answered by erhan on 30 Nov 2013

I have to plot a signals in a MATLAB gui.

With Simulink I make a simulation and I save the signal in the workspace. I want to plot that signal in a gui axes but I dont know what I have to do.




4 Answers

Answer by Arnaud Miege on 31 May 2011
Accepted answer

I assume you run the Simulink model from the MATLAB GUI using the sim command. The data from your Scope will end up in the GUI (caller) workspace rather than the base workspace. So you should be able to plot it using something like:

plot(ScopeData.time, ScopeData.signals.values)

You may need to specify the handle of the axis on which to plot the data.

Also have a look at this technical solution.




andoni on 31 May 2011

i run the simulation in simulink, it's necesary to run it from gui??

Arnaud Miege on 31 May 2011

No, it isn't, but you indicated that you want to plot the signals in the MATLAB GUI, so I logically assume that you wanted to run the Simulink model from the GUI as well. It does have the advantage that the data will be readily available in the GUI workspace rather than the base workspace.

andoni on 1 Jun 2011

thank you so much!

Arnaud Miege
Answer by Walter Roberson on 31 May 2011

Are you using a "To Workspace" block? If so then when you look at the variable, what class() and size() is it? And what kind of plot are you thinking of?


Fangjun Jiang on 31 May 2011

Use the command that Amaud Miege gave above.
plot(ScopeData.time, ScopeData.signals.values)

Walter Roberson on 31 May 2011

Though before that you might need to add

ScopeData = evalin('base', ScopeData);

in order to import the data from the base workspace in to the workspace of the current function.

andoni on 1 Jun 2011

thank you so much!

Walter Roberson
Answer by Nuno Agualusa on 28 Jan 2012


I'm facing the same problem, but with a small diference. I'm running the simulink from GUI, but when the simulation finish doesn't apear a variable 'simout' in my base workspace. So i can´t plot the result on axes. I'm using a variable block in simulink, to get all the data to worspace. The only way that i found to get a variable in base workspace, is to run the simulation manualy in simulink.

what can i do to solve this situation?

Thank you very much.



Kaustubha Govind on 30 Jan 2012

How are you running the SIM command? You might want to set 'DstWorkspace' to 'current' to make sure that Simulink uses your GUI function workspace as the destination workspace.

Nuno Agualusa on 30 Jan 2012

yes, the running command that i used is:


The problem is when a simulation ends i can't plot in my GUI axes the result of the simulation..and this action has to be peformed only trought out GUI.

Nuno Agualusa
Answer by erhan on 30 Nov 2013

I want set guı axes from scope value. Can you give example ?



Contact us