How to create an array in Simulink to save data and process these data in Simulink
174 次查看(过去 30 天)
显示 更早的评论
Dear all,
I want to create an array in Simulink to save the satified data and then deal with these data in Simulink. For example, there is a system made by a'step function' and a sine wave with 100 Hz frequency. The sampling frequency of this system is 1 kHz. Now, assumeing a rising edge from the step function at 0.1 s, how to capture and save the one cycle data ( the circled part in the following figure) in Simulink? Moreover, if I want to do some online calculation in Simulink with the saved data, can I use the 'MATLAB function' block as what we did in the MATLAB?
Thank you for your help.
Di
0 个评论
回答(2 个)
Rhea Chandy
2021-1-5
Hi!
You can save data from Simulink to a MAT-file using the To File block. To save it as an array, specify the Save format parameter as Array. Further, you can specify the sample period and offset at which to collect data points using the Sample time parameter.
You can also consider writing the input signal data to a workspace using the To Workspace block, however the data will not be available until the simulation pauses or stops.
Tamir Suliman
2023-1-24
you can use the "To Workspace" block to save data to a variable in the MATLAB workspace. You can then use the "From Workspace" block to bring the data back into a Simulink model for further processing.
- To save data to an array, place a "To Workspace" block in your model.
- In the block's parameters, specify the variable name you want to use for the array (e.g. "myArray") and the "Save format" (e.g. "Array").
- Connect the signal you want to save to the input of the "To Workspace" block.
- To bring the data back into the model, place a "From Workspace" block in your model.
- In the block's parameters, specify the same variable name you used in step 2 (e.g. "myArray").
- Connect the output of the "From Workspace" block to the input of the block where you want to process the data.
Then you can use standard simulink block to process these data.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!