Simulink and Memory and Matlab Function Block
20 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Tong Zhao
2022-5-15
编辑:Tong Zhao
2022-5-16
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!