%% Determine if Timetable Is Regular
% Create a timetable by 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')

% Copyright 2012 The MathWorks, Inc.