Required Matlab code with explanatory comments is given below:
function avg=Q_myavg(A)
avg=zeros(1,5); %initialize averages array
for k=1:5 %for each year
avg(k)=mean(A(52*(k-1)+1:52*k)); %find the
average of each year
end
end
Sample usage:
Hope this was helpful. Please do leave a positive rating if you liked this answer. Thanks and have a good day!
Get Answers For Free
Most questions answered within 1 hours.