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.

回答(1 个)

Sandeep Mishra
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:
  • 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
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.

类别

Help CenterFile Exchange 中查找有关 Create Block Masks 的更多信息

标签

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by