# How to customize the Simulink Scope!21

Posted by Seth Popinchalk,

As we all know, there is a tool for each job. You can hit a nail with a screwdriver, but the job is easier with a hammer. It’s the same thing to display Simulink data. One common question I receive in technical support is how to customize the Simulink Scope. My answer to this question is simple: Do not customize the Simulink Scope… use simplot.

With simplot, you can easily take the data from a Simulink Scope that looks like this:

And create a MATLAB figure with annotations, legend and labels.

The Simulink Scope is an optimized display designed to run fast during simulation. Its job is to show signals while the simulation is running. For post-simulation analysis, creating reports and presentations, a MATLAB figure is more appropriate. The simplot function helps by plotting simulation data in a MATLAB figure that looks like the Simulink Scope.

To plot the output of a Simulink model in a MATLAB figure, the first step is to save the data to the MATLAB workspace using one of these 3 options:

• The “Save Data to Workspace” option of Simulink Scopes
• To Workspace blocks
• Root-level Outport blocks

To create the figure above, I saved the output of a Scope block to the variable ScopeData:

After simulating the model, I used simplot to create the figure:

simplot(ScopeData)
legend('Position','Velocity')
annotation('ellipse',[0.68  0.25  0.15  0.12],...
'EdgeColor','red',...
'LineWidth',3);
annotation('textarrow',[.5 .68],[.2 .3],...
'TextEdgeColor','none',...
'TextLineWidth',3,...
'TextBackgroundColor',[1 .9 .8],...
'FontSize',12,...
'Color','red',...
'LineWidth',3,...
'String','I want to show this');


How do you visualize the data coming out of your simulations?

Bob replied on : 1 of 21

This was very useful. I’ve wondered how to be able to work with simulink time scope output, edit, make it useful for presentations. Thanks for doing this!

OysterEngineer replied on : 2 of 21

I agree with Bob. This is a very practical blog entry. Keep them coming.

bahar replied on : 3 of 21

I want to know how simulink analyse electrical circuits?
I mean I want to find the c code of any block.
thank you.

kryon replied on : 4 of 21

hi Im confused about the ph input in complex phase shift block.What sort of phase input should I give.I tried to give a constant but it showed something else.Im actually trying to have a phase shift of 4 in a Voltage signal.

wei replied on : 5 of 21

@Guy, Now it’s official that simplot will be gone in a future release. Do you know if Simulink.sdi will have all simplot’s capability? What;s future for Signal and Scope Manager?

Thomas replied on : 6 of 21

This seems less like a solution and more like a work around.

I had this problem recently: I wanted to show a simulation in front of a big audience. But the purple line on a black background is just not visible on the projector, so this was a very poor experience.

Messing around with plot is not an option in a lecture, so is there a proper solution to the problem? Ideally it would show the scope on a white background, and use stronger lines than the “default” (or only) option.

Fabian replied on : 7 of 21

Guy, great tip. Now, add that to StopFcn callback of the scope block and the new figure appears automatically after the simulation.

Carlos replied on : 8 of 21

Completely agree with Thomas (6): that is just a work-around, and not very convenient to be honest. Other software tools like SimulationX have already much better display options as Simulink. I think it’s time you update your scopes.

– Scopes should be dockable means “Drag&drop”.
– One should be able to change the color of the signals easily with a palette.
– Legends should be a “toggle” button in the scope and should show by default the name of the signals, even when they come from a bus or a mux.

Like already said, take a look at Dymola oder SimulationX and copy the good ideas.

Nuno Pimenta replied on : 9 of 21

Hi Guy Rouleau, congrats for the post…
If i save this image in JPG or EPS, the image appear without title and time… I can change this?

André replied on : 10 of 21

Great hint for that found in another thread:

1. Open the Scope window you want to copy
2. In the MATLAB command window, execute the following code:

set(0,’ShowHiddenHandles’,’on’)

Now it’s easily configurable, can be exported to most graphic file formats, …

Darshan Pandit replied on : 12 of 21

Hey, thanks seth.

I did some harmonic analysis with matlab & had too many waveforms on the scope. I wanted to label it till now.

good way pointed by you over here…

aidin replied on : 13 of 21

It was very useful but I still have a question. When I plotted the Simulink output in MATLAB figure, I used Data cursor tool to figure out the coordinates of a specific point, but when I moved the data cursor on the graph I figured out that the accuracy of the graph is not that good.After that, I plotted another figure by Simulink and transferred it to MATLAB figure and in that time I understood that the figure is not appropriate. Now my question is: How can I improve or arise the precision of my figures in Simulink?

Seth replied on : 14 of 21

@aidin – It is hard to know exactly what was wrong with the plots of your simulation data, but I’m guessing you are concerned about the number of points in the output (you want more points in your output). I think you will find a discussion of the Refine Factor helpful. Good luck!

Chris replied on : 15 of 21

I see the solution here as a work around. Given the scope is such a fundamental part of simulink it needs some real usability updates. Give it some of the same capabilities a real hardware scope has. Cursors, measurements, graph naming, color coding, FFTs, copy to figure. A third party company that works with simulink has a great solution, but it’s part of a much bigger (expensive) package.

Razvan replied on : 16 of 21

I can’t seem to be able to contain a simplot in a subplot or custom position axes, it just occupies most of the figure regardless. How do I do this?

An alternative solution would be to open a different figure and tweak its ‘Position’ parameter, but I’m still curious whether I could work with a single figure.

Seth replied on : 17 of 21

@Chris – Thanks for the feedback and suggestions!

@Razvan – The SIMPLOT function is an M-file. You can make your own copy of it and change it’s behavior to meet your needs. It is also a convenience to get the basic look of a classic Scope in a MATLAB figure. Because Simulink scopes are allowed to have multiple axes, SIMPLOT is built with the assumption that it can use the entire figure area.

Razvan replied on : 18 of 21

@Seth – Thank you!

Fred replied on : 19 of 21

Hi,

Do you know of any method I can use to save an image of a scope from simulink to use it for image processing in the same model?

Anuj replied on : 20 of 21

If You have 3 or 4 outputs, means if you want to see 3 or 4 plots in different scopes, then how to work with simplot and this legend? Thanks in advance.

SyuhadaM replied on : 21 of 21

Thanks billions times men! you save me a billions time (s) :))

What is 5 + 6?

Preview: hide