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

See if you can figure this MATLAB program out The display must be done using fpr

ID: 2902898 • Letter: S

Question

See if you can figure this MATLAB program out The display must be done using fprintf:

The average monthly precipitation (in.) for Boston and Seattle during 2012 are given in the

vectors below (data from the U.S. National Oceanic and Atmospheric Administration).

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]

Where the elements in the vectors are in the order of the months (January, February, etc.)

Write a program in a script file to answer the following:

(a)

Calculate the total precipitation for the year and monthly average precipitation in each

city.

(b) How many months was the precipitation greater than 6.23 in each city?

(c) How many months, and on which months, was the average precipitation in Seattle

greater than the precipitations in Boston

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