Effacer les filtres
Effacer les filtres

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 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

madhan ravi
madhan ravi le 25 Nov 2023
Modifié(e) : madhan ravi le 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

Plus de réponses (0)

Catégories

En savoir plus sur Configure and View Diagnostics dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by