Embedded Matlab Fuction Access of Subsystem Mask Parameters
4 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
Is it possible to access a subsystem's mask parameters from an embedded matlab function within that subsystem? I tried referencing the parameter name directly and I also tried the get_param function, neither of which worked. get_param(gcb,'myParameter') generated the following error: "The function 'gcb' is not supported by Embedded MATLAB for code generation. See the documentation for eml.extrinsic to learn how you can use this function in simulation." I looked at eml.extrinsic and did not immediately see how this would help me access parameters. Any help will be greatly appreciated.
Thanks,
Phillip
1 件のコメント
Kyle Huggins
2018 年 12 月 20 日
I know this is 6 years old, but I wanted to comment for future users. In order to access a masked parameter inside a matlab function block, you have to add your variable as an input into the matlab function.
Prerequisites. A mask set up correctly for a referenced model. See the reference documentation for how to do it.
1) Open the model explorer
2) click on and expand your referenced model
3) click on the matlab function inside your referenced model
4) on the taskbar, add a new data entry
5) set the name to your model workspace variable's name (same one that's masked as a parameter)
6) change the scope to "Parameter" (this is the important bit)
You're done! The variable should appear as a function argument in your matlab function, and it should have the masked value specified in the calling model. As long as all the names match up, it should work.
回答 (2 件)
Kaustubha Govind
2012 年 3 月 7 日
Embedded MATLAB Function Block parameters need to have the same name as the variable that holds its value, so you need to define your mask parameter variable name so that it matches that of the Embedded MATLAB block. If that's not possible, in the Mask Initialization pane, simply create a variable whose name matches that of the Embedded MATLAB parameter, and assign the value of the mask parameter to it.
I'd advise against using gcb because it returns whichever block is currently selected on the model, which doesn't have to be the masked subsystem. The error that you see asking you to use eml.extrinsic is because the Embedded MATLAB block only allows use of functions supported for code-generation, and the get_param function is not one of them.
2 件のコメント
Kaustubha Govind
2012 年 3 月 8 日
If you have already defined your mask variables with the same name as the EML block parameters, you shouldn't have to use get_param(gcb,'myParameter') - just use the parameter name 'myParameter'. You may need to configure the parameters appropriate in the block's Ports and Data Manager (Tools>Edit Data/Ports on the EML Editor window).
Bala kumar
2015 年 6 月 23 日
Hi Phillip,
try the above link that will help you to get idea how to access the mask system parameter by a matlab function block.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Subsystems についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!