How I can change the simulink variable value from matlab gui?

4 visualizaciones (últimos 30 días)
ander
ander el 5 de Nov. de 2014
Respondida: ander el 5 de Nov. de 2014
Good morning everyone, and excuse me for my English.
I have a GUI in Matlab and my objective is to change the value, for example, the all m variable I am using in the simulink model. For example, if I am using the m variable 5 times in different places like gain or constant blocks, I want to change the value of all them.
I know that to change one block value is this command: set_param(object,param,value);
Another doubt I have is why simulink give me an error when I have the values assigned in the workspace. Simulink says that it didn`t know the value of the parameters.
thanks!

Respuesta aceptada

Orion
Orion el 5 de Nov. de 2014
Hi
Simulink actually uses the variables defined in the base workspace, not the local workspace of your function.
here, if i run my function test, i get an erreor because simulink doesn't know the value of m, only defined in the script.
you can send the value of your different parameters in the base workspace using assignin.
and all the blocks using m as a parameter will be updated for the simulation (same for the others variables).

Más respuestas (1)

ander
ander el 5 de Nov. de 2014
Thank you, it was the command I need

Categorías

Más información sobre Event Functions 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!

Translated by