www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SpecifyToleranceToMatchRowTimesExample.m
%% Specify Tolerance to Match Row Times % Create a timetable that contains temperature and pressure data with row times % in hours. There is a slight random variance in the row times. Select rows % with row times that match corresponding times in a time vector within a tolerance % of five seconds. Time = datetime(2015,12,18) + hours(1:10)' + seconds(randn(10,1)); Temp = [37.3 39.1 42.3 42.6 43 43.9 44.1 43.3 42.5 42]'; Pressure = [29.4 29.6 30.0 30.0 30.1 29.9 29.9 29.8 29.6 29.7]'; TT = timetable(Time,Temp,Pressure) %% % Create a time vector spanning the hours from 3:00 to 8:00. newTimes = datetime(2015,12,18) + hours(3:8) %% % Select rows of |TT| with row times that match times in |newTimes| within % five seconds. S = withtol(newTimes,seconds(5)); TT2 = TT(S,:)