Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# setuniformtime

Class: timeseries

Modify uniform time vector of timeseries object

## Syntax

ts2 = setuniformtime(ts1,'StartTime',StartTime)
ts2 = setuniformtime(ts1,'Interval',Interval)
ts2 = setuniformtime(ts1,'EndTime',EndTime)
ts2 = setuniformtime(ts1,'StartTime',StartTime,'Interval',Interval)
ts2 = setuniformtime(ts1,'StartTime',StartTime,'EndTime',EndTime)
ts2 = setuniformtime(ts1,'Interval',Interval,'EndTime',EndTime)

## Description

ts2 = setuniformtime(ts1,'StartTime',StartTime) returns the time series with a modified uniform time vector, determined from the StartTime and Interval 1. EndTime = StartTime + (length(ts1) - 1). The unit of time is unchanged.

ts2 = setuniformtime(ts1,'Interval',Interval) sets the StartTime to 0, and uses EndTime = (length(ts1) - 1)*Interval.

ts2 = setuniformtime(ts1,'EndTime',EndTime) sets the StartTime to 0, and uses Interval = EndTime/(length(ts1) -1).

ts2 = setuniformtime(ts1,'StartTime',StartTime,'Interval',Interval) uses EndTime = StartTime + (length(ts1) - 1) * Interval.

ts2 = setuniformtime(ts1,'StartTime',StartTime,'EndTime',EndTime)uses Interval = (EndTime - StartTime)/(length(ts1) - 1).

ts2 = setuniformtime(ts1,'Interval',Interval,'EndTime',EndTime) uses StartTime = EndTime - (length(ts1) - 1) * Interval.

## Input Arguments

 ts1 timeseries object to which you want to assign a uniform time vector. StartTime Start time of uniform time vector, specified as a numeric value. Interval Time interval of uniform time vector, specified as a numeric scalar value. EndTime End time of uniform time vector specified as a numeric scalar value.

## Output Arguments

 ts2 Time series with uniform time vector, returned as a timeseries object.

## Examples

### Specify New Start Time

Modify the uniform time vector of time series data by specifying a new start time.

`load count.dat;`
2. Create a timeseries object.

`count_ts = timeseries(count,1:length(count),'Name','CountPerSecond');`
3. Modify uniform time vector of count_ts.

`count_ts = setuniformtime(count_ts,'StartTime',10);`

The start time of the time vector is 10 seconds. setuniformtime uses a default time interval of 1 and computes the end time using: EndTime = StartTime + (length(count_ts) - 1)* Interval.

### Specify New Start and End Times

Modify the uniform time vector of time series data by specifying a new start time and end time.

`load count.dat;`
2. Create timeseries object.

`count_ts = timeseries(count,1:length(count),'Name','CountPerSecond');`
3. Assign a uniform time vector to count_ts.

`count_ts2 = setuniformtime(count_ts,'StartTime',10,'EndTime',20);`

The start time of the time vector is now 10 seconds, and the end time is now 20 seconds. MATLAB® computes the time interval using: Interval = (EndTime - StartTime)/(length(count_ts) - 1)