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 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
madhan ravi
2023-11-25
编辑:madhan ravi
2023-11-25
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Configure and View Diagnostics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!