using scope in Matlab Simulink to display when input's value changes
66 views (last 30 days)
Show older comments
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


Answers (1)
Sulaymon Eshkabilov
on 18 Feb 2023
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
2 Comments
Sulaymon Eshkabilov
on 20 Feb 2023
Most welcome! Glad to help. So you accept the suggested solution :)
See Also
Categories
Find more on Programmatic Model Editing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!