Is it possible to add custom block parameters to Simulink blocks in Simulink 7.8 (R2011b)?
5 ビュー (過去 30 日間)
古いコメントを表示
I would like to add custom parameters to built-in blocks in my Simulink model. For example, if the model, 'myModel' contains the Gain Block, 'gain1' I would like to add a parameter 'myParam' to this block so that I may access it via:
get_param('myModel/gain1', 'myParam')
set_param('myModel/gain1', 'myParam', some_value)
Moreover, I would like for the value of the parameter to persist after I save and close the model's MDL file.
採用された回答
MathWorks Support Team
2011 年 11 月 15 日
The ability to add custom parameters to built-in blocks is not available in Simulink 7.8 (R2011b). To work around this issue, starting in Simulink 7.8 (R2011b) it is possible to mask built-in blocks which do not already have a mask. This may be done by right-clicking on the block and choosing 'Create Mask'. Within the Mask Editor dialog, block parameters may be added to the block that are accessible via the functions GET_PARAM and SET_PARAM.
In versions before Simulink 7.8 (R2011b), the block parameter 'UserData' may be used to store the desired values. Also, the parameter 'UserDataPersistent' may be set to 'on' in order to save the data stored in 'UserData' in the model file. For example:
set_param('myModel/gain1', 'UserData', myData)
set_param('myModel/gain1', 'UserDataPersistent', 'on')
would save the value 'myData' in 'UserData' and specify that it should be stored in the MDL file after the model is saved and closed.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Programmatic Model Editing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!