Creating States with a MATLAB Function Block
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 30 de En. de 2018
Respondida: MathWorks Support Team
el 27 de Feb. de 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?
Respuesta aceptada
MathWorks Support Team
el 30 de En. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!