MATLAB: Help with how to include a mean value calculator in a for-loop

for loopmean value

Hey, I have a problem where I have a vector that have a value for insolation for every hour during a year. I want create a for loop that takes the first 24 elements in that vector and the calculates the average value for this elements. The number will later represent the insolation for a whole day. After the first calulation I want the calculatur (i), to jump forward 24 steps so the next calulation represent the averges insolation for the next day.
My problem Is that I don't know how to make the calculator to jump forward 24 steps after the first loop. As my script acts now It determine the mean value but it's only steps forward one element for each loop, which results in that insolation values from one day apperece in several averge values.
Thanks for all the help
clear all
soldataimport = importdata("soldata.xls");
%The vectors with data for each year
sol2015 = str2double(soldataimport.x2015);
sol2016 = str2double(soldataimport.x2016);
sol2017 = str2double(soldataimport.x2017);
sol2018 = str2double(soldataimport.x2018);
sol2019 = str2double(soldataimport.x2019);
%Vector that every mean value will be placed in and represent the
%insolation for the hole day
arsol2015 = zeros(1,365);
for i = 1:length(sol2015)
arsol2015(i) = mean(sol2015(i:i+24));
end

Best Answer

Does this do what you want?
arsol2015 = mean(reshape(sol2015,24,[]));
Although not needed, your loop could be this
for i = 1:24:length(sol2015)