- toolbox\matlab\timeseries\+tsdata\@interpolation\interpolation.m for the implementation of tsdata.interpolation (in particular the interpolate method)
- toolbox\matlab\timeseries\tsArrayFcn.m which is called by interpolate
- toolbox\matlab\timeseries\tsinterp.m for the implementation of the three default interpolation methods.
Avoid interpolation while synchronizing time series
4 views (last 30 days)
Show older comments
Hi, I am using the "synchronize" function in Matlab to synchronize two time series. By default this function linearly interpolates the data when missing values. I would like to prevent this and keep the missing values in the synchronized time series. One of the options accepted for interpolation methods is "tsdata.interpolation", an object that contains a user-defined interpolation method. It must be the way to avoid interpolation but I have no clue on how to define this object. Anyone could help? Thanks a lot! Alice
0 Comments
Answers (2)
Guillaume
on 21 Sep 2014
That's one very badly documented function indeed! If I were you, I'd raise an issue with mathworks.
Note, the following is based on looking at the source code in version 2013b which does not have synchronise but does have tsdata.interpolation. It's possible it's different in your version.
First, there are two other predefined methods. I've no idea what they do, the code has very little comment, but you can try them like so:
%zoh method ??? at some point builds an histogram
interpmethod = tsdata.interpolation.createZOH;
%or you can create it with
interpmethod = tsdata.interpolation('zoh');
%nan method ???
interpmethod = tsdata.interpolation('nan');
%if you wanted to create the default:
interpmethod = tsdata.interpolation.CreateLinear;
%or
interpmethod = tsdata.interpolation('linear');
If none of these do what you want you need to create your own interpolation method. It would have the following signature:
function newdata = myinterp(newtime, oldtime, olddata)
%do whatever you want
end
You then create the interpolation object with:
interpmethod = tsdata.interpolation(@myinterp);
Hope this helps. Note, you can look at the source code yourself in
0 Comments
Star Strider
on 21 Sep 2014
What do ‘missing values’ mean?
Are the sampling times present but the signal values at those times are missing, or are there gaps with neither sampling times nor signal values?
[ts1 ts2] = synchronize(ts1,ts2,'union','KeepOriginalTimes',true);
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!