Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How to initialize variables (parameters) in Simulink

Asked by Kiran Sagar on 16 Jul 2013

I have a model of a mechanical system in simulink, which has a lot of parameters which are NOT variables mathematically speaking. eg. Mass, length of a body.

i have some fixed values for these parameters which do not change during the simulation. my model is having many user-defined blocks and in each block i have to initialize the same variables.

is there any method by which i can initialize variables in common for all user-defined blocks. OR may be i could initialize these variables in a file and extract it.

1 Comment

Kiran Sagar on 16 Jul 2013

the primary aim is to have a single source of the parameter values, so that i need not go to each block to change the value of single parameter

Kiran Sagar

Tags

Products

1 Answer

Answer by Kaustubha Govind on 16 Jul 2013

Yes, typically this kind of initialization is done using MATLAB code that is called from the model InitFcn callback, so that the code is run every time the model is compiled or run. If you want the parameters to be created only once when the model is open, you can use the PostLoadFcn callback.

0 Comments

Kaustubha Govind

Contact us