Simulink Plot from Command Window
4 次查看(过去 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'.
0 个评论
采纳的回答
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.
Regards,
stozaki
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!