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!