- In the MATLAB R2017b “MATLAB Function” block, navigate to the Editor tab and click on “Edit Data” in the Simulink section.
- In the Symbols pane, click the “Add Data” button.
- Define a new variable with the same name as the mask parameter (for example, “V_ca”).
- Set the “Scope” property of variable to “Parameter”
why can't Simulink get the variable initialized in mask?
8 次查看(过去 30 天)
显示 更早的评论
As it has been shown in picture, I have initialized the variable in mask, but still can't compile.
I have tried to use the model properties - callbacks to initialize the variables, but failed too.
0 个评论
回答(1 个)
Sandeep Mishra
2024-10-10
Hi,
I encountered a similar issue while calling the mask variable inside the “MATLAB function” block after declaring it as a parameter in the subsystem’s mask.
To resolve this error, you can create a variable within the “MATLAB Function” block and set its scope to “Parameter”.
Refer to the following steps to create and access the variable:
After implementing these steps, you will see an additional parameter in the “MATLAB function,” which will be linked to the mask parameter.
Refer to the following MathWorks Documentation to learn more about “Use Data in Multiple MATLAB Function Blocks by Defining Parameter Variables”: https://www.mathworks.com/help/simulink/ug/parameter-arguments-in-matlab-function-block-functions.html
I hope this helps you.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Create Block Masks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!