Not able to change the values of the voltage source on Simulink
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rosheen Hassan
el 27 de Nov. de 2022
Respondida: Sameer Pujari
el 30 de Nov. de 2022
I've modelled a buck converter on simulink and wish to change the values of the voltage source using set_param in the m file. I created a vector that contains the values of Vin I want my buck to run on (min was 1 and max was 300V) and set a for loop to iterate 200 times as below
for i = 1:200
set_param('bs/DC_V', 'Amplitude', num2str(Voltage_IN(i)));
end
When I run the simulation my voltage source stays constant on 300, the last value in my vector and doesnt vary from 1 to 300 as I wanted. Can someone explain why this is so and what am I doing wrong?
0 comentarios
Respuesta aceptada
Sameer Pujari
el 30 de Nov. de 2022
Hi Rosheen
I understand that you want to change the value of a certain block parameter and then simulate the model for that certain value
In your code snippet, the for loop is setting the value of the parameter as per the array but is not simulating the model for the certain value. Hence at the end you could only see the last value in the array
You can use the following way to set the parameter and simulate the model.
Voltage_IN=linspace(1,300,200);
for i = 1:200
%Creates SimulationInput objects to make changes to model for multiple or individual simulation
in(i)=Simulink.SimulationInput('vdp');
%Set a certain Gain values for each Simulation input
in(i)= in(i).setBlockParameter('vdp/Mu', 'Gain', num2str(Voltage_IN(i)));
end
% Simulate a model with the sim function by using the specified techniques to specify parameter values.
out= sim(in,'ShowSimulationManager','on','ShowProgress','on')
% Logged signals during the simulation can be viewed
plot(out)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Switches and Breakers en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!