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
How to initialize variables (parameters) in Simulink
56 次查看(过去 30 天)
显示 更早的评论
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 个)
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
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 Center 和 File Exchange 中查找有关 Simulink Environment Customization 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!