- To Workspace block - https://www.mathworks.com/help/simulink/slref/toworkspace.html
- Run Simulations programmatically - https://www.mathworks.com/help/simulink/ug/using-the-sim-command.html
How to save Variable in workspace from real time simulation with timestamps
4 次查看(过去 30 天)
显示 更早的评论
Hello I have a real time simulation in Simulink and i would like to save the date/variables in workspace with timestamps. i tried it with scope block. but it is just showing the current value.
please help.
0 个评论
回答(1 个)
ag
2024-12-27
编辑:ag
2024-12-27
Hi Siyaram,
I understand that you want to store the simulation output in the MATLAB workspace with timestamps.
To achieve this, you can employ the "To Workspace" block in Simulink, which allows you to write data directly to the MATLAB workspace. Configure the "To Workspace" block parameters like "Variable name" and "Save Format" as per your needs(by default it's set to "Timeseries").
Below is a self-explanatory script that demonstrates how you can run the model and extract the output data from the "To Workspace" block:
% Define the Simulink model name
modelName = 'your_model_name';
% Simulate the model
out = sim(modelName);
% Extract the output from the "To Workspace" block
% assuming the variable name is set to default "simout"
toWksData = out.simout;
% Extracting the time and data from the output
time = simout.Time;
data = simout.Data;
For more details, please refer to the following MathWorks documentations:
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Real-Time 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!