How to execute Simulink subsystem only if a specific variable exists in the workspace?
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a Simulink model and 2 different scripts that initialize it. There are some variables that aren't initialized by one script, and are initialized by the other. How would I set up my Simulink model such that a subsystem is executed if a variable that is only initialized by Script 1 is present in the workspace? I found this thread, but even after implementing that I get a compile time Simulink error that says the following. How do I fix this?
Invalid setting in 'MODEL' for parameter 'Value'
> Caused by: Undefined variable foo.
0 Commenti
Risposte (1)
Moe_2015
il 7 Lug 2022
You can make use of and convert your subsystems to variant subsystems: https://www.mathworks.com/help/simulink/ug/variant-subsystems.html
In your scripts you can have a variabe called DoesfooExist = exist(foo,'var'). For the variant that the variable exists, in the block parameters of the variant subsystem, set the expression to DoesfooExist == 1. The other variant can be DoesfooExist == 0 and the block just outputting zeros. That way when you use script 1, the block is executed as you want. When using script 2, it will use the variant that does not have that variable.
0 Commenti
Vedere anche
Categorie
Scopri di più su Component-Based Modeling in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!