Can I plot an entire vector in the Simulink Data inspector ?
8 views (last 30 days)
Show older comments
Ronan
on 22 Jul 2020
Answered: Hari Veerubhotla
on 16 Sep 2020
I often save data in the Simulation data inspector (SDI) when I run a model to analyse the results. I work with a lot of vectors and I'm looking for a way to plot all the elements of the vectors in the same plot. For now, I only managed to plot elements individualy but the dimension of the vecteur is to large to select all of them one by one.
Do you know a way to do that ?
0 Comments
Accepted Answer
Hari Veerubhotla
on 16 Sep 2020
Hi,
As per my understanding, you have a vector of signals which are you are planning to plot in SDI at once.
If you are planning to do this through UI, you can select the RUN in Simulink Data Inspector and click CONTROL + A + SPACE, which will plot all the signals under that RUN.
Selecting a set of signals inside a RUN and pressing SPACE would basically check/uncheck the signals and subsequently plot/un-plot them from the plot area.
If you are planning to this through programmatically, you can iterate over list of signals in the RUN and use the plotOnSubPlot() APi to plot signals.
Below is the code-snippet which does that.
// creating vector with list of signals.
sine_vals = sin(2*pi/5*time);
sine_ts = timeseries(sine_vals,time);
sine_ts.Name = 'Sine, T=5';
cos_vals = cos(2*pi/8*time);
cos_ts = timeseries(cos_vals,time);
cos_ts.Name = 'Cosine, T=8';
vec = [sine_ts, cos_ts]
// Run creation with created vector
runID = Simulink.sdi.createRun("Sample_Run","vars", vec);
runObj = Simulink.sdi.getRun(runID);
// Launch SDI
Simulink.sdi.view;
//Iterate over signals and plot them in SDI
for index = 1:runObj.SignalCount
signalObj = runObj.getSignalByIndex(i);
// Plot signal on the first plot in the layout
plotOnSubPlot(signalObj, 1,1,true);
end
-Thanks
0 Comments
More Answers (0)
See Also
Categories
Find more on Analyze Simulation Results in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!