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

    %% Apply Multiple Methods to Timetable
% Load a timetable. Adjust the timetable variables using the |retime|
% function and different methods for different variables.
%
% Load a timetable with temperature, wind speed, and rainfall measurements
% for Boston.
load(fullfile(matlabroot,'examples','matlab','bostonTT'));
Boston
%%
% Adjust the data to produce daily mean temperatures and wind speeds, 
% and daily sums of the rainfall. |retime| applies the same method to all 
% timetable variables. To apply different methods, index into the timetable
% to select variables, and call |retime| for each method you use.
BOS = Boston(:,{'Temp','WindSpeed'});
TT1 = retime(BOS,'daily','mean')

%%
BOS = Boston(:,'Rain');
TT2 = retime(BOS,'daily','sum')

%%
% To combine all results in one timetable, concatenate |TT1| and |TT2|.
TT = [TT1 TT2]