Update M-script parameter value Continuously based on Workspace Data fed by a Simulink Model
Mostrar comentarios más antiguos
I am simulating a Simulink model for n seconds run from a Matlab script. In the Simulink model, I have a parameter that is being saved in the workspace. Now, based on the workspace data, I want to continuously update a parameter in m-file and feed the updated value in the Simulink model. After having an if else statement in the m-file, I see my target parameter is not being updated in the Simulink model.
For example, in my Simulink model, I have a DC bus current, Idc is being generated. I have the Idc stored in the workspace using the “To Workspace” block. Now, based on the magnitude of Idc, which is saved in the workspace, I want to update the switching frequency, fsw in m-script CONTINUOUSLY. Then, I want the the Simulink model, which is being simulated, should get the updated value of fsw continuously from the m-script.
For example, I tried this way but it does not help!
if Idc < 100
fsw = 100e3;
else
fsw = 200e3;
end
This code does not update the value of fsw continuously in the Simulink model. Any help would be appreciated!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre General Applications en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!