Simulink and Memory and Matlab Function Block

47 vues (au cours des 30 derniers jours)
Andrea Carroll
Andrea Carroll le 27 Jan 2020
Modifié(e) : Tong Zhao le 16 Mai 2022
Would anyone know how to store muliptle values of data during a simulink program. I have tried to use the Data Store Memeory Block in Simulink, however this only stores one value at any one time and then is updated when it gets a new input. Any ideas?
Also when using Matlab Function blocks is there a way of storing values for later use. For example, is it possible to create an array to store mulitple inputs which you will then process at a later time? (So far I have not managed to do this) Any ideas of how to solve this problem?

Réponses (1)

Tong Zhao
Tong Zhao le 15 Mai 2022
Modifié(e) : Tong Zhao le 16 Mai 2022
You can use a Memory block outside the MATLAB Function block to store your values, then send the output of the Memory block back into the MATLAB Function block. I know this is not pretty, but easy and fast if you only have a couple of variables to worry about. If you have a large number of data to store, try bundle them into an array if possible, so you don't have to deal with a large number of Memory blocks.
Or if you want the memory to be within the MATLAB Function block for tidyness, you can use persistent variables. A limitation of persistent variable though, is that you cannot use it when your Simulink is running variable step solver.

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by