| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
[ts1 ts2] = synchronize(ts1,ts2,'SynchronizeMethod')
[ts1 ts2] = synchronize(ts1,ts2,'SynchronizeMethod') creates two new timeseries objects by synchronizing ts1 and ts2 using a common time vector. The string 'SynchronizeMethod' defines the method for synchronizing the timeseries and can be one of the following:
'Union' — Resample timeseries objects using a time vector that is a union of the time vectors of ts1 and ts2 on the time range where the two time vectors overlap.
'Intersection' — Resample timeseries objects on a time vector that is the intersection of the time vectors of ts1 and ts2.
'Uniform' — Requires an additional argument as follows:
[ts1 ts2] = synchronize(ts1,ts2,'Uniform','Interval',value)
This method resamples time series on a uniform time vector, where value specifies the time interval between the two samples. The uniform time vector is the overlap of the time vectors of ts1 and ts2. The interval units are assumed to be the smaller units of ts1 and ts2.
You can specify additional arguments by using property-value pairs:
'InterpMethod': Forces the specified interpolation method (over the default method) for this synchronize operation. Can be either a string, 'linear' or 'zoh', or a tsdata.interpolation object that contains a user-defined interpolation method.
'QualityCode': Integer (between -128 and 127) used as the quality code for both time series after the synchronization.
'KeepOriginalTimes': Logical value (true or false) indicating whether the new time series should keep the original time values. For example,
ts1 = timeseries([1 2],[datestr(now); datestr(now+1)]); ts2 = timeseries([1 2],[datestr(now-1); datestr(now)]);
Note that ts1.timeinfo.StartDate is one day after ts2.timeinfo.StartDate. If you use
[ts1 ts2] = synchronize(ts1,ts2,'union');
the ts1.timeinfo.StartDate is changed to match ts2.TimeInfo.StartDate and ts1.Time changes to 1.
But if you use
[ts1 ts2] = synchronize(ts1,ts2,'union','KeepOriginalTimes',true);
ts1.timeinfo.StartDate is unchanged and ts1.Time is still 0.
'tolerance': Real number used as the tolerance for differentiating two time values when comparing the ts1 and ts2 time vectors. The default tolerance is 1e-10. For example, when the sixth time value in ts1 is 5+(1e-12) and the sixth time value in ts2 is 5-(1e-13), both values are treated as 5 by default. To differentiate those two times, you can set 'tolerance' to a smaller value such as 1e-15, for example.
![]() | symvar | syntax | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |