Clear Filters
Clear Filters

Use Retime of a timetable to interpolate to timestamps of another timetable, without interpolating across NaNs

7 views (last 30 days)
I am trying to interpolate values within one timetable to the timestamps in another timetable. However, I do not want to interpolate across gaps where NaNs exist, which occurs when using the standard retime function.
For example:
I have continuous data here with time on the left, and values on the right. This timetable is named "CC"
'12/12/2010 09:30' 0.119000000000000
'12/12/2010 09:45' NaN
'12/12/2010 10:00' NaN
'12/12/2010 10:15' NaN
'12/12/2010 10:30' NaN
'12/12/2010 10:45' NaN
'12/12/2010 11:00' NaN
'12/12/2010 11:15' NaN
'12/12/2010 11:30' NaN
'12/12/2010 11:45' NaN
'12/12/2010 12:00' NaN
'12/12/2010 12:15' NaN
'12/12/2010 12:30' NaN
'12/12/2010 12:45' 0.105000000000000
I would like to linearly interpolate these values to the timestamp below. This timetable is named "CSE"
'12/12/2010 12:00' 0.127000000000000
When I use retime to interpolate CC to the time of CSE, I would like it to return NaN , but instead it interpolates across the gap.
CSEC=retime(CC,CSE.meanTime_CST_,'linear');
The output is this:
'12/12/2010 12:00' 0.108230769230769

Answers (1)

Walter Roberson
Walter Roberson on 9 May 2024
Specify a function handle for the retime aggregation method.
"All the listed methods omit NaNs, NaTs, and other missing data indicators, except for func. To include missing data indicators, specify func as a function handle to a function that includes them when aggregating data."
  1 Comment
David Dean
David Dean on 9 May 2024
Im not sure I know how to create a function handle for this example...I posted snippets of my timetables here to better illustrate what is happening.
I have continuous data here with time on the left, and values on the right. This timetable is named "CC"
'12/12/2010 09:30' 0.119000000000000
'12/12/2010 09:45' NaN
'12/12/2010 10:00' NaN
'12/12/2010 10:15' NaN
'12/12/2010 10:30' NaN
'12/12/2010 10:45' NaN
'12/12/2010 11:00' NaN
'12/12/2010 11:15' NaN
'12/12/2010 11:30' NaN
'12/12/2010 11:45' NaN
'12/12/2010 12:00' NaN
'12/12/2010 12:15' NaN
'12/12/2010 12:30' NaN
'12/12/2010 12:45' 0.105000000000000
I would like to linearly interpolate these values to the timestamp below. This timetable is named "CSE"
'12/12/2010 12:00' 0.127000000000000
When I use retime to interpolate CC to the time of CSE, I would like it to return NaN, but instead it interpolates across the gap.
CSEC=retime(CC,CSE.meanTime_CST_,'linear');
The output is this:
'12/12/2010 12:00' 0.108230769230769
I don't know how to write a function handle that does not interpolate across that gap...

Sign in to comment.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!