Question

The global temperature of the planet was recorded every week for 5 years. That makes 52*5...

The global temperature of the planet was recorded every week for 5 years. That makes 52*5 = 260 temperatures. Write an algorithm having: - as a parameter, the list of real values corresponding to the 260 temperatures in the order of recording: 1st week of the 1st year, 2nd week of the 1st year, ..., 52nd week of the 1st year, 1st week of the 2nd year, 2nd week of the 2nd year, ..., 52nd week of the 5th year ; - as a result, the list of the 5 average temperatures of each year (i.e., the list of real temperatures constituted by of the average of the first 52 values, then the average of the next 52 values, and so on).

Homework Answers

Answer #1

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!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions