why can't Simulink get the variable initialized in mask?

3 views (last 30 days)
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.

Answers (1)

Sandeep Mishra
Sandeep Mishra on 10 Oct 2024
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.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!