%%%Date range example

start_year = 1980;
end_year = 2010;

% Calucllate number of years in the data
nyears = end_year - start_year + 1;

dt = datenum(0, 0, 0, 0, 30, 0); %time step is 30 minutes

%Create a vector of dates for one year, with 30 minutes step
%select a non-leap year
dates_for_one_year = datevec(datenum(1981,1,1): dt: datenum(1982,1,1) - dt);

dates_for_all_years = repmat(dates_for_one_year, nyears, 1);

months = dates_for_all_years(:, 2);

%%Calculate season column from months column
%% 1 - Winter, 2 - Spring, 3 - Summer, 4 - Autumn
seasons = idivide(int32(months), int32(3), 'floor') + 1;
seasons(seasons == 5) = 1;

%%%Why Can't I do just this
%%dates_for_all_years= datevec(datenum(1980,1,1):dt:datenum(2011, 1,1) - dt)


figure
    hold on
    
    hm = plot(months);
    hs = plot(seasons, 'red');

    grid on
    
    legend([hm hs], 'months', 'seasons');
    hold off
    
    
    
