using scope in Matlab Simulink to display when input's value changes

66 次查看(过去 30 天)
How do display all output in one scope when input's value chance:
EX:
Transfer of system is 1/(s^2+a*s+1) with a = {1:1:10}
a is declared in matlab then it is used for Simulink

回答(1 个)

Sulaymon Eshkabilov
It is a very intersting exercise. There are a few different ways to get simulation results for different values of a as defined in the exercise. Here are a couple of ways:
(1) Everything in Simulink. The variable "a" is also defined inside Simulink as a look up table via Model Explorer options. All 10 simulation results for a = [1 2 3 .. 10] are stored inside one scope block.
% sim('VerA_Loop.slx') % All simulation results are stored in one simulink
% S = sim("VerA_Loop.slx"); % ALL Sim results are stored in one scope
% for a = 1:10
% plot(S.Sout.time, S.Sout.signals(a).values)
% hold all
% L{a} = ['a = ' num2str(a)];
% legend(L{:})
% end
(2) Simulation is called from MATLAB and results are obtained/augmented in MATLAB (not exactly as given in the assignment)
for a = 1:10
S=sim("VerB_Loop.slx");
plot(S.Out(:,1),S.Out(:,2))
hold all
L{a} = ['a = ' num2str(a)];
legend(L{:})
SimOUT{a} = S.Out; % ALL Sim results are stored
end

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by