Azzera filtri
Azzera filtri

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?

9 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

madhan ravi
madhan ravi il 25 Nov 2023
Modificato: madhan ravi il 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

Più risposte (0)

Categorie

Scopri di più su Author Block Masks in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by