Clear Filters
Clear Filters

Why don't I get a direct error message for an undefined mask variable of a Simulink block if this is a partly undefined structure element?

6 views (last 30 days)
I define my mask variables, which I use in the Simulink models, via a structure. In my workspace, for example, the structure element "modelParameter" is defined with the parameters "Vol" and "d". If I now mistakenly enter, for example "modelParameter.f" in the mask of a block/model, Matlab does not issue an error message. However, this parameter does not exist, but there is no direct error message such as with a normal double variable: "Variable 'xx' does not exist". In addition, the input field for the corresponding mask parameter is not highlighted in red as usual. Why is that? Can I change that?

Accepted Answer

madhan ravi
madhan ravi on 25 Nov 2023
Edited: madhan ravi on 25 Nov 2023
Looks like by default it doesn’t highlight in red when it’s a struct field which is undefined.
You could either give each mask parameter a "prompt" with the field name or write your own callback to check if the field exist in the "workspace" then throw dialog error message.
but I would suggest you not to do this.
Anyways at the end you will be getting an error during Simulation when the variable is undefined. So I don’t see the struggle of reinventing the wheel for this specific purpose.
Or use a different approach instead of mask and pass the values as Simulink Parameters https://de.mathworks.com/matlabcentral/answers/2050862-how-to-pass-a-struct-to-a-model-reference-instance

More Answers (0)

Categories

Find more on Configure and View Diagnostics in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!