Azzera filtri
Azzera filtri

Simulink and Memory and Matlab Function Block

18 visualizzazioni (ultimi 30 giorni)
Andrea Carroll
Andrea Carroll il 27 Gen 2020
Modificato: Tong Zhao il 16 Mag 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?

Risposte (1)

Tong Zhao
Tong Zhao il 15 Mag 2022
Modificato: Tong Zhao il 16 Mag 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.

Categorie

Scopri di più su Programmatic Model Editing in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by