Simulink - Set and use global variable for use in settings
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
tisoul
am 4 Aug. 2017
Beantwortet: Sebastian Castro
am 4 Aug. 2017
Hello everyone,
I was wondering if it was possible to define by any way a global variable (scope of an entire Simulink model) and use it in "Settings" we get by double-clicking an element in Simulink.
For instance, I'd like to define something like "Vcc" and use that for all my CMOS gates in an electrical circuit.
0 Kommentare
Akzeptierte Antwort
Sebastian Castro
am 4 Aug. 2017
Absolutely. All you need to do is define a variable in the MATLAB workspace, for example:
>> Vcc = 5;
... and then any block that uses Vcc in its block parameters can pick this up.
The next step is to have these variables be automatically created when you open the model, by sticking this code in the pre-load callback of the model. https://www.mathworks.com/help/simulink/ug/using-callback-functions.html
- Sebastian
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Sources 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!