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

***THIS IS DONE IN MATLAB*** Download the data file on D2L (HW4_Problem1_Data.xl

ID: 671285 • Letter: #

Question

***THIS IS DONE IN MATLAB***

Download the data file on D2L (HW4_Problem1_Data.xlsx) (Which I have provided the info above. just a heads up. in the excel sheet. it has more rows than colums. this is done 3x32 it needs to be 32x3.) which shows the maximum daily temperatures in Chicago and San Francisco during the month of August 2009 and import the data in Matlab using the ‘xlsrea d’ command.

Day

a. Calculate the average maximum daily temperatures for each city.

b. How many days was the maximum temperatures above the average from part a? Calculate this for both Chicago and San Francisco.

c. How many days, and on which dates in the month, was th e temperature in San Francisco lower than the temperature in Chicago?

d. How many days, and on which dates in the month, was the temperature the same in both cities?

e. Plot the temperatures for each city in one plot. For Chicago, plot the data using a black “x ” at each data point and a black line connecting the data points. For San Francisco, plot the data using a red “o” at each data point and a red dashed line connecting the data points. Include a legend in an appropriate location. Don't forget to label each axis. The y-limits of the plot should be 50 to 100 degrees F

Day

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Chicago 75 79 86 86 79 81 83 89 91 86 81 82 86 88 89 90 82 84 81 79 73 69 73 79 82 72 66 71 69 66 66 San Fransisco 69 68 70 73 72 71 69 76 85 87 74 84 76 68 79 75 68 68 73 72 79 68 68 69 71 70 89 95 90 66 69

Explanation / Answer

l = [[1 75 69]; [2 79 68]; [3 86 70]; [4 86 73]; [5 79 72]; [6 81 71]; [7 83 69]; [8 89 76]; [9 91 85]; [10 86 87]; [11 81 74]; [12 82 84]; [13 86 76]; [14 88 68]; [15 89 79]; [16 90 75]; [17 82 68]; [18 84 68]; [19 81 73]; [20 79 72]; [21 73 79]; [22 69 68]; [23 73 68]; [24 79 69]; [25 82 71]; [26 72 70]; [27 66 89]; [28 71 95]; [29 69 90]; [30 66 66]; [31 66 69]];

% average maximum daily temperatures
temp_c = 0.0;
temp_f = 0.0;
for i = 1:31
temp_c = temp_c + l(i,2);
temp_f = temp_f + l(i,3);
end

avg_c = temp_c/31
avg_f = temp_f/31


% How many days was the maximum temperatures above the average from part a? Calculate this for both Chicago and San Francisco.
days_c = 0;
days_f = 0;
for i = 1:31
if (l(i,2) > avg_c)
days_c = days_c + 1;
end
if (l(i,3) > avg_f)
days_f = days_f + 1;
end
end

% How many days, and on which dates in the month, was th e temperature in San Francisco lower than the temperature in Chicago?

days = 0;
dates = [];
for i = 1:31
if (l(i,2) > l(i,3))
days = days + 1;
dates(:,i) = i;
end
end

days
dates


% How many days, and on which dates in the month, was the temperature the same in both cities?

days = 0;
dates = [];
for i = 1:31
if (l(i,2) == l(i,3))
days = days + 1;
dates(:,i) = i;
end
end

days
dates