******* USE MATLAB ************ Element-wise Algebra: Below are the daily temper
ID: 2293441 • Letter: #
Question
******* USE MATLAB ************
Element-wise Algebra: Below are the daily temperatures (degrees Fahrenheit) for each day of February. (The 1st element is February 1st.) 3. 48 43 39 36 41 44 51 55 52 45 44 38 37 34 36 36 42 44 49 47 46 50 52 54 56 58 60 62 a. Convert all temps to Celsius using: C (5/9) (F-32) b. Use built-in functions to find the minimum, maximum, and average temperatures for the month, as well as the day at which the max and min occurred. (the following 3 step process lets you find the day) i. Use the optional 2nd output argument for the min/max functions to determine the location in the matrix where min/max occur. ii. Create a new 4x7 matrix containing the "days of the month" ie: the 1 st row is the numbers 1-7, 2nd row is 8-14,etc. ii. Use the index location determined in part i to find the appropriate day within the matrix of days from part ii Suppose next year's forecast calls for progressively hotter and hotter days. On Feb 1st of next year, it is to be one degree hotter than Feb 1st of this year, and Feb 2nd is to be 2 degrees hotter than Feb 2nd of this year, etc. Add these temperature increases to matrix F to find out the temperatures next year. c. i. Create a row vector of the temp increases 1 through 28. ii. Reshape this vector into a 7x4 matrix using the reshape function ii. Transpose the 7x4 matrix to turn it into the proper 4x7 size. iv. Use element-wise addition to add this new matrix to matrix F. (Steps i-ii simply created the same matrix that you created on step b.ii. However, I wanted you to practice using the reshape and transpose functions to see how these functions can be utilized.)Explanation / Answer
%1. Creating a matrix Ff, temperature in Faurenheit of month February
Ff=[48 43 39 36 41 44 51; 55 52 45 44 38 37 34; 36 36 42 44 49 47 46;50 52 54 56 58 60 62]
%a) converting into celsius
Fc=(5/9)*(Ff-32)
%b) Calculating Min and Max
I=[1:7;8:14;15:21;22:28]; % Date of the months
[Min,Loc1]=min(Ff); % to find the min value and the loci of the values in each column
[Min1,Loc2]=min(Min);
MinDate=I(Loc1(Loc2),Loc2);
fprintf('The minimum Temperature is %dF on February %d ',Min1,MinDate);
[Max,Loc3]=max(Ff); % to find the max value and the loci of the values in each column
[Max1,Loc4]=max(Max);
MaxDate=I(Loc3(Loc4),Loc4);
fprintf('The maximum Temperature is %dF on February %d ',Max1,MaxDate);
Ffa=mean(Ff); % to find the average value
avgFf=mean(Ffa);
fprintf('The Average Temperature is %fF ',avgFf);
%
%c) Forecasting
Temp=1:28;
Temp=reshape(Temp,7,4); % reshaping an array of size 1x28 into 7x4
Temp=Temp'; % Transpose of the reshaped array
FfNew=Ff+Temp % element wise addition of two matrices
% ANS is as follows
% Ff =
%
% 48 43 39 36 41 44 51
% 55 52 45 44 38 37 34
% 36 36 42 44 49 47 46
% 50 52 54 56 58 60 62
%
%
% Fc =
%
% 8.8889 6.1111 3.8889 2.2222 5.0000 6.6667 10.5556
% 12.7778 11.1111 7.2222 6.6667 3.3333 2.7778 1.1111
% 2.2222 2.2222 5.5556 6.6667 9.4444 8.3333 7.7778
% 10.0000 11.1111 12.2222 13.3333 14.4444 15.5556 16.6667
%
% The minimum Temperature is 34F on February 14
% The maximum Temperature is 62F on February 28
% The Average Temperature is 46.392857F
%
% FfNew =
%
% 49 45 42 40 46 50 58
% 63 61 55 55 50 50 48
% 51 52 59 62 68 67 67
% 72 75 78 81 84 87 90
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.