How to incrementally save output data from long Simulink simulation?

Hey everyone,
I'm using Simulink to compute the response of a linear, parameter varying system (LPV system). Within the simulation 24h data shall be generated with a sample frequency of 800 Hz. I'd like to save the output incrementally every 10 minutes.
My question is: How can I perform these blockwise savings?
Thanks
Stefan

 Accepted Answer

You can specify the start and stop time of the simulation. The key point is to save the final state of the last simulation and use it as the initial state of the next simulation. Below is an example, you can change the loop number and insert the save command inside the loop to save your data.
vdp;
tStart='0';
tStop='10';
out=sim('vdp','StartTime',tStart,'StopTime',tStop,...
'SaveFormat','Structure',...
'SaveFinalState','On','FinalStateName','xFinal');
for k=1:1
tStart=tStop;
tStop=num2str(10+k*10);
x0=out.xFinal;
out=sim('vdp','StartTime',tStart,'StopTime',tStop,...
'SaveFormat','Structure',...
'LoadInitialState','On','InitialState','x0',...
'SaveFinalState','On','FinalStateName','xFinal');
end

1 Comment

Hey,
this is also the solution I finally implemented successfully. Many thanks.
Stefan

Sign in to comment.

More Answers (0)

Categories

Find more on Communications Toolbox in Help Center and File Exchange

Products

Release

R2018a

Asked:

on 30 May 2018

Commented:

on 1 Jun 2018

Community Treasure Hunt

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

Start Hunting!