I need help with plotting Simulink output in Matlab

12 ビュー (過去 30 日間)
Swarupendra Chakraborty
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
  1 件のコメント
Swarupendra Chakraborty
Swarupendra Chakraborty 2020 年 9 月 16 日
Thanks for that, This fix worked!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by