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

66 visualizaciones (últimos 30 días)
Do
Do el 18 de Feb. de 2023
Comentada: Sulaymon Eshkabilov el 20 de Feb. de 2023
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

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 18 de Feb. de 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 comentarios
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 20 de Feb. de 2023
Most welcome! Glad to help. So you accept the suggested solution :)

Iniciar sesión para comentar.

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by