Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write in MATLAB... 8. The average monthly precipitation (in.) for Boston and li

ID: 3681946 • Letter: W

Question

Write in MATLAB...

8. The average monthly precipitation (in.) for Boston and li 5 15 35 70 Seattle during 2012 are given in the vectors below (data from the U.S. National Oceanic and Atmospheric Administration). BOS E [2.67 1.00 1.21 3.09 3.43 4.71 3.88 3.08 4.10 2.62 1.0 5.9 SEA [6.83 3.63 7.20 2.68 2.05 2.96 1.04 0.00 0.03 6.71 8.28 6.85] where the elements in the vectors are in the order of the months (January, Feb- ruary, etc. Write a program in a script file to answer the following (a) Calculate the total precipitation for the year and monthly average precipi- tation in each city. (b How many months was the precipitation above the average in each city? (c) How many months, and on which months, was the precipitation in Boston lower than the precipitation in Seattle?

Explanation / Answer

clear all;
close all ;
BOS = [2.34 .86 1.56 3.89 2.56 6.74 3.55 7.65 9.75 2.34 5.32 8.53];
SEA = [6.43 5.24 3.45 .67 1.23 4.54 6.45 8.54 7.84 1.34 3.54 4.87];
fprintf('solving part (a) ');
a= sum(BOS);
b= a/12;
c= sum(SEA);
d= c/12;
fprintf(' the total precipitation for the year in boston is %.4f ', a);
fprintf(' the average for the year in boston is %.4f ', b);
fprintf(' the total precipitation for the year in seattle is %.4f ', c);
fprintf(' the average for the year in seattle is %.4f ', d);

fprintf('solving part (b) ');
A= (BOS-BOS)+6.23;
B=BOS>A;

C=SEA>A;
a=sum(B);
b=sum(C);
fprintf(' for %.0f months the precipitation was greater than 6.23 in boston ', a);
fprintf(' for %.0f months the precipitation was greater than 6.23 in seattle ', b);
fprintf('solving part (c) ');
C= SEA>BOS;
i=1;
a= sum(C);
fprintf(' for %.0f months the precipitation was greater in seattle than boston ', a);

fprintf('the months are ');
while i<13
if C(i)>0
if i==1
fprintf('January ');
end
if i==2
fprintf('february ');
end
if i==3
fprintf('march ');
end
if i==4
fprintf('april ');
end
if i==5
fprintf('may ');
end
if i==6
fprintf('june ');
end
if i==7
fprintf('july ');
end
if i==8
fprintf('august ');
end
if i==9
fprintf('september ');
end
if 1==10
fprintf('october ');
end
if i==11
fprintf('november ');
end
if i==12
fprintf('december ');
end
end
i=i+1;
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote