How to initialize variables (parameters) in Simulink

조회 수: 56 (최근 30일)
Kiran Sagar
Kiran Sagar 2013년 7월 16일
댓글: Ting Liang 2020년 12월 1일
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
Kiran Sagar
Kiran Sagar 2013년 7월 16일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2013년 7월 16일
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.
  댓글 수: 1
Ting Liang
Ting Liang 2020년 12월 1일
Hi, Kaustubha,
Excuse me.
Can I ask whether it is possible to set up a M file(M code) to achieve parameter initialization? Cause if I use InitFcn to initialize the parameters, they cannot be annotated, some time later, it would be difficult for me to recognize these parameters?
Thanks.
Best regards

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by