Chop vectors in between a specific time range?

I run a simulation in Matlab/Simulink for 10 seconds and the output data is stored in the workspace.
But I need to save data between 5 to 10 seconds to the workspace.
How is this possible ?

 Akzeptierte Antwort

K E
K E am 20 Aug. 2012
Bearbeitet: K E am 20 Aug. 2012

0 Stimmen

I think you are running a Simulink model and outputting values for your entire 10-second simulation using the To Workspace block. In Matlab, you can then extract the data collected between 5-10 seconds from your saved value as follows. Let us say you rename your time variable timeSimulation and your dependant variable temperature.
temperatureExtracted = temperature(timeSimuation >= 5 & timeSimulation <= 10) ;
If this is not what you want to do, please provide more specifics as Jan suggested.

Weitere Antworten (2)

Jan
Jan am 19 Aug. 2012

0 Stimmen

Omit the first interval before 5.
Currently the lack of details in the question does not allow a more precise suggestion.
Gautham Jayakumar
Gautham Jayakumar am 21 Aug. 2012
Bearbeitet: Gautham Jayakumar am 21 Aug. 2012

0 Stimmen

Hi KE
Thank you for the help. It works fine, anyways for others references in the future i will leave more details about my exact case.
I run a simulink model which outputs Torque with variable name Te. Simulation time is 1 second. a fault occurs at 0.30 second. Hence i need to collect the torque between 0.30 seconds to 1 second.
using KE's code: I get Te as output from the simulation, and chop the vectors between 0.30 to 1 second and save it under the name Te1.
timesimulation = 1;
ftime = 0.30;
Te1 = Te(timesimulation >= ftime & timesimulation <= 1) ;

Kategorien

Mehr zu Simulink finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by