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

Monthly average rain fall in inches in Jasper, GA and Clarkston GA are as below:

ID: 3675236 • Letter: M

Question

Monthly average rain fall in inches in Jasper, GA and Clarkston GA are as below: Jasper: 12.59, 11.08, 12.19, 13.87, 9.50, 5.40, 14.99, 15.20, 14.70, 11.65, 12.56, 6.11 Clarkston: 10.80, 8.01, 4.98, 8.65, 6.05, 4.76, 9.02, 4.31, 8.56, 7.45, 4.22, 6.16 Write a script file in MATLAB to perform the following: a. Compute and display average rain fall for the entire year for each city b. Compute and display the number of months the rain fall was above average in each city c. Determine and display number of months the rain fall in Jasper was lower than that in Clarkston Output should be user-friendly and with appropriate units.

Explanation / Answer

%Save file as rainfall.m

%matlab-code that process rainfall of two cities

%a)

%jasper rainfall vector

jasper=[12.59 11.08 12.19 13.87 9.50 5.40 14.99 15.20 14.70 11.65 12.56 6.11];

%Clarkston rainfall vector

Clarkston=[10.80 8.01 4.98 8.65 6.05 4.76 9.02 4.31 8.56 7.45 4.22, 6.16];

%set jasperTotal =0

jasperTotal=0;

%set clarkstonTotal=0

clarkstonTotal=0;

%find total rainfall for two cities

for i=1:12

jasperTotal=jasperTotal+jasper(i);

clarkstonTotal=clarkstonTotal+Clarkston(i);

end

%find average rainfall for two cities

jasperavg=jasperTotal/12;

disp('Jasper averagea rain fall',jasperavg);

clarkstonavg=clarkstonTotal/12;

disp('Clarkston averagea rain fall',clarkstonavg);

%b)

%count cities that more than average for jasper and clarkston

avgcount1=0;

for i=1:12

if jasper(i)>jasperavg

avgcount1=avgcount1+1;

end

end

disp('Cities more than above average for city jasper ',avgcount1);

avgcount2=0;

for i=1:12

if Clarkston(i)>clarkstonavg

avgcount2=avgcount2+1;

end

end

disp('Cities more than above average for city Clarkston ',avgcount2);

%c)

%count number of cities that are lower than clarkston rainfall

lower=0;

for i=1:12

if jasper(i)<Clarkston(i)

lower=lower+1;

end

end

disp('Number of cities of jasper lower than rainfall of clarkston rainfall', lower);


----------------------------   ----------------------------   ---------------------------- ----------------------------

Sample output:

Jasper averagea rain fall
   11.6533
Clarkston averagea rain fall
    6.9142
Cities more than above average for city jasper
7
Cities more than above average for city Clarkston
6
Number of cities of jasper lower than rainfall of clarkston rainfall
1

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