Temperatures in Chicago and San Francisco The maximum daily temperature (degree
ID: 3563896 • Letter: T
Question
Temperatures in Chicago and San Francisco The maximum daily temperature (degree F) for Chicago and San Francisco during the part ial month of August 2009 are given in the data arrays below (data from the U.S. National Oceanic and Atmospheric Administration). ChiTemp = [75 79 86 80 79 81 73 89 91 86 81 82 86 88 89 00 82 84 81 79 73 69] SFTemp = (69 68 70 73 72 71 69 76 85 87 74 81 76 68 79 75 68 68 73 72 79 68) Construct script files in MAT LAB (c) for each of the exercises. Control and detail your output using fprintf using no decimal values modeling each execution output below. Calculate the average temperature for the month in each city. .Name your script file tempAnalysisA.m. As an example, see the following execution output: How many days was the temperature above the average in each city? Name your script file tempAnalysisB.m. As an example, see the following execution output: How many days was the temperature in San Francisco lower than the temperature in Chicago? Name your script file tempAnalysisC.m.Explanation / Answer
% all the three functions are as follows.
% tempAnalysisA
ChiTemp=[75 79 86 86 79 81 73 89 91 80 81 82 86 88 89 90 82 84 81 79 73 69];
SFTemp=[69 68 70 73 72 71 69 76 85 87 74 84 76 68 79 75 68 68 73 72 79 68];
ChiAvg=mean(ChiTemp);
SFAvg=mean(SFTemp);
fprintf('Chicago average temperature: %f Degrees ',ChiAvg);
fprintf('San Francisco average temperature: %f Degrees ',SFAvg);
________________________________________________________________________________________
% tempAnalysisB
ChiTemp=[75 79 86 86 79 81 73 89 91 80 81 82 86 88 89 90 82 84 81 79 73 69];
SFTemp=[69 68 70 73 72 71 69 76 85 87 74 84 76 68 79 75 68 68 73 72 79 68];
ChiAvg=mean(ChiTemp);
SFAvg=mean(SFTemp);
c1=0;
c2=0;
for i=1:size(ChiTemp,2)
if(ChiTemp(1,i)>ChiAvg) c1=c1+1;
end
end
for i=1:size(SFTemp,2)
if(SFTemp(1,i)>SFAvg) c2=c2+1;
end
end
fprintf('Days above Chicago average temperature: %d Days ',c1);
fprintf('Days above San Francisco average temperature: %d Days ',c2);
_______________________________________________________________________________________
% tempAnalysisC
ChiTemp=[75 79 86 86 79 81 73 89 91 80 81 82 86 88 89 90 82 84 81 79 73 69];
SFTemp =[69 68 70 73 72 71 69 76 85 87 74 84 76 68 79 75 68 68 73 72 79 68];
c1=0;
for i=1:size(ChiTemp,2)
if(ChiTemp(1,i)>SFTemp(1,i)) c1=c1+1;
end
end
fprintf('Days cooler in San Francisco than Chicago: %d Days ',c1);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.