Simulink and Memory and Matlab Function Block
28 Ansichten (letzte 30 Tage)
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?
Tong Zhao am 15 Mai 2022
Bearbeitet: Tong Zhao am 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.