www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/DetermineIfTimetableIsRegularExample.m
%% Determine if Timetable is Regular % Create a timetable using a monthly time vector. Determine whether it is % regular with respect to time, and then with respect to months. % % Create a timetable whose row times are the first five months of % the year |2016|. Add the monthly price of a stock as a table variable. StockPrice = [109.0;107.82;113.17;128.01;116]; M = timetable(datetime(2016,1:5,3)',StockPrice) %% % Determine whether |M| is a regular timetable. TF = isregular(M) %% % |M| is not regular because the first five months have different numbers % of days. You can use the |diff| function to calculate the differences in % the time steps between consecutive times in |M|. The differences are % durations, formatted to display the time steps as hours, minutes, and % seconds. D = diff(M.Time) %% % Determine whether |M| is regular with respect to months, by specifying % |'month'| as the unit of measure. TF = isregular(M,'months')