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!