I need help with plotting Simulink output in Matlab

조회 수: 34 (최근 30일)
Swarupendra Chakraborty
Swarupendra Chakraborty 2020년 9월 16일
댓글: Swarupendra Chakraborty 2020년 9월 16일
So I am trying to plot a function from the simulink output, usingthe 'to workspace' block, but whenever I try to use the output and plat it with Matlab, the following error code appears
>> Prob_1c_ass_1_1813081
Error using timeseries/plot (line 27)
The plot method can only be used for a single timeseries object
Error in Prob_1c_ass_1_1813081 (line 2)
plot(out.tout, out.u);
My code is:
subplot(3, 1, 1)
plot(out.tout, out.u);
title('u vs t')
xlabet('t')
ylabel('u = 2sin2t')
subplot(3, 1, 2)
plot(out.tout, out.y);
title('y vs t')
xlabet('t')
ylabel('y')
subplot(3, 1, 3)
plot(out.tout, out.u, out.tout, out.y);
legend('u', 'y')
title('(u, y) vs t')
xlabet('t')
ylabel('u, y')
Could anyone help me find what I might be doing wrong?
Thanks

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 9월 16일
It depends on your saving format. It looks like you have "single simulation output" checked and the format is "dataset". Press Ctrl+E and click "Data Import/Export" on the left column.
In this case, you can do plot(out.u) directly to show the plot.
To dive deep, check this value in Command Window
out.u.Time
out.u.Data

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by