Can I plot an entire vector in the Simulink Data inspector ?

조회 수: 3 (최근 30일)
Ronan
Ronan 2020년 7월 22일
답변: Hari Veerubhotla 2020년 9월 16일
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 ?

채택된 답변

Hari Veerubhotla
Hari Veerubhotla 2020년 9월 16일
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개)

카테고리

Help CenterFile Exchange에서 Analyze Simulation Results에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by