MATLAB: How to vector with the same length of matrix

dataMATLABmatrixtime seriesvector

Hi everyone,
I have to do a vector with the same lenght of matrix. This new vector should contain a package of hour from 1 to 8766, one time that it arrives to end point (8766) it must restarts from 1 and arrives to 8766 and this for the all length of the matrix. I hope to have been clear enough. Thank you.
File = 'D:\Valerio\data\Time_dir_Analysis\Analisys\data\a_ERA5.xlsx';
readFile = xlsread(File);
ERA5 = unique(readFile,'rows');
dt_ERA5 = datetime([ERA5(:,1:4) repmat([0 0],size(ERA5,1),1)]);
tt_ERA5 = timetable(dt_ERA5,ERA5(:,5:end));

Best Answer

Try something like this
n = size(ERA5,1);
hours_vector = mod((1:n)-1,8766)+1;
hours_vector is like this
hours_vector = [1 2 3 .. .. 8765 8766 1 2 3 .. .. 8765 8766 ..]