www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/InterpolateTimetableDataToArbitraryTimesExample.m

    %% Interpolate Timetable Data to Arbitrary Times
% Create a timetable that contains times, temperature, and pressure
% readings taken approximately at the half-hour mark, but with one
% measurement from 9:00 AM missing.
Time = datetime({'2015-12-18 07:29:53';'2015-12-18 08:00:00';...
                 '2015-12-18 08:31:02';'2015-12-18 09:30:00'});
Temp = [37.3;41.9;45.7;39.8];
Pressure = [30.1;29.9;30.03;29.8];
TT1 = timetable(Time,Temp,Pressure)

%%
% Create a regular time vector and interpolate the data based on it. To resample 
% the data from |TT1| using linear interpolation, specify |'linear'|.
newTimes = [datetime('2015-12-18 07:30:00'):minutes(30):datetime('2015-12-18 09:30:00')];
TT2 = retime(TT1,newTimes,'linear')