Simulink Plot from Command Window

조회 수: 4 (최근 30일)
Ayyron
Ayyron 2020년 8월 29일
댓글: Ayyron 2020년 8월 30일
How can I plot my simulink data from the command window or script?
When I do i get:
>> sim('HW1_number10')
ans =
Simulink.SimulationOutput:
ScopeData: [53x3 double]
tout: [53x1 double]
yout: [1x1 Simulink.SimulationData.Dataset]
SimulationMetadata: [1x1 Simulink.SimulationMetadata]
ErrorMessage: [0x0 char]
>> plot(tout,ScopeData)
Undefined function or variable 'tout'.

채택된 답변

stozaki
stozaki 2020년 8월 30일
편집: stozaki 2020년 8월 30일
Hello Aaron,
Please try as follows.
% execute model simulation and store the result in y.
y = sim('HW1_number10');
% acquisition of time data. idx is the outport block number.
% For example 1,2,3...
time = y.yout{idx}.Values.Time;
% acquisition of data. idx is the outport block number.
% For example 1,2,3...
data = y.yout{idx}.Values.Data;
% plot on figure
plot(time,data);
Set the output port number you want to display in idx.
Please refer to Run Simulations Programmatically for other acquisition methods and applications.
Regards,
stozaki
  댓글 수: 1
Ayyron
Ayyron 2020년 8월 30일
Perfect, thank you so much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by