How to save Variable in workspace from real time simulation with timestamps

5 vues (au cours des 30 derniers jours)
siyaram bhatt
siyaram bhatt le 22 Jan 2017
Modifié(e) : ag le 27 Déc 2024
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.

Réponses (1)

ag
ag le 27 Déc 2024
Modifié(e) : ag le 27 Déc 2024
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!

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by