Creating States with a MATLAB Function Block
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 30 Gen 2018
Risposto: MathWorks Support Team
il 27 Feb 2018
I want to include a Matlab algorithm in my model that has information which needs to persist over multiple time steps. Can I do this with a MATLAB Function block?
Risposta accettata
MathWorks Support Team
il 30 Gen 2018
It is possible to model state behavior using a MATLAB Function block, by declaring the state variable as 'persistent'. However, this is not the recommended workflow if you need information to persist through multiple time steps, since these blocks can only "fake" a state using a persistent variable. This is simple to implement, but has limitations since persistent variables cannot be logged, stored, or retrieved in Simulink.
There are several other options for implementing a MATLAB algorithm in Simulink. The following documentation page is a wonderful resource for comparing the different options for implementing a MATLAB algorithm in a Simulink model:
It is recommended to review this page before making a final choice about which block to use to implement your algorithm, since it discusses many considerations to make when choosing between the options (e.g. code generation, performance). The section on "Model State Behavior" discusses which options can work with states.
Finally, one option that is not mentioned on the above page is to use Stateflow.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Simulink Functions 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!