Main Content

time

Extract time vector from simulation series

Description

example

tv = time(series) returns a row vector of simulation times contained in the series. series is a simscape.logging.Series object. series must include a full identifier path to the series, starting with the workspace log variable name.

Examples

collapse all

Return simulation time data for the deformation of a Translational Spring block.

Open the Mass-Spring-Damper with Controller example model:

ssc_mass_spring_damper_control

This example model has data logging enabled for the whole model, with the Workspace variable name parameter set to simlog_ssc_mass_spring_damper_control.

Simulate the model for 1 second, to log the simulation data:

paramNameValStruct.StopTime = '1.0';
sim('ssc_mass_spring_damper_control',paramNameValStruct);

Return the simulation time vector for the deformation variable of the Translational Spring block, Spring. x is the deformation variable name, and series is the Series object containing the simulation data for this variable.

t1 = time(simlog_ssc_mass_spring_damper_control.Spring.x.series)
t1 =

         0
    0.0072
    0.0143
    0.0223
    0.0323
    0.0447
    0.0602
    0.0799
    0.1064
    0.1447
    0.1833
    0.2114
    0.2395
    0.2776
    0.3248
    0.3531
    0.3814
    0.4194
    0.4650
    0.4940
    0.5230
    0.5608
    0.6056
    0.6356
    0.6657
    0.7033
    0.7467
    0.7772
    0.8077
    0.8451
    0.8877
    0.9263
    0.9572
    0.9858
    1.0000

The t1 vector has 35 values, between 0 and 1, because the simulation series has 35 time steps and the simulation stop time is 1 second.

Input Arguments

collapse all

Simulation series, specified as a simscape.logging.Series object. series must include a full identifier path to the series, starting with the workspace log variable name.

Output Arguments

collapse all

Times, in seconds, corresponding to the time steps in the simulation series, returned as a row vector.

Introduced in R2010b