Filter löschen
Filter löschen

variables from model input in simulink mask

3 Ansichten (letzte 30 Tage)
E Luttringer
E Luttringer am 13 Jun. 2024
Hello,
I'm struggling with Simulink, to make the link beetwen a model input and variables usable in block masks. For exemple, the "Compare To Constant" block proposes some tuning parameters in its masks, but I need to make them available as model inputs, for example "cval" for the constant to compare with. (This is just for illustration purpose, I know that it exists a comparison bloc with two entries).
If the "cval" variable exists in the base or model workspace, there is no error and the "Step" function works without other artifices. But the value is fixed and shall be changed with a new matlab command cval=<new value>. A matlab function bloc with "assignin" command could do the job, but the "assignin" function does not work with code generation.
In my case I want to customize the parameter "cval" through a model input, but I don't know how to do.
Does somebody has a solution?
Thanks

Antworten (1)

Jean-Paul Marcade
Jean-Paul Marcade am 19 Jun. 2024
Hi,
The parameter writer block is probably what you are looking for (https://www.mathworks.com/help/simulink/slref/parameterwriter.html). The workflow is explained in this other thread : https://www.mathworks.com/matlabcentral/answers/2000912-how-can-i-enter-a-mask-parameter-to-a-block-through-an-input-block-in-simulink-r2021b (From R2022b, this is more straightforward)

Kategorien

Mehr zu Event Functions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by