% Problem{09}: Given two arrays (67 x 10) of weather data (67 cities, 10 % days)
ID: 2268006 • Letter: #
Question
% Problem{09}: Given two arrays (67 x 10) of weather data (67 cities, 10
% days) (format below), calculate the information described:
% Filename: Filename: weather_03.m
% Input:
% LowTemps.mat (A Matlab variable file that contains LowTemps (67 x 10))
% HighTemps.mat (A Matlab variable file that contains HighTemps (67 x 10))
% Output:
% MaxDifferentialInDayTemp (1 x 1)
% MinDifferentialInDayTemp (1 x 1)
% MaxDifferentialBetweenDayTemp (1 x 1)
% MinDifferentialBetweenDayTemp (1 x 1)
% Note: Use HighTemps for the Min and Max Differential Between Day Temp.
% Also, this is defined as the difference between day N+1 and day N.
I know you can't run the program without the .mat files, but I just need to know how to write a script to calculate the difference in days and between days. If it helps each data collection file is 67 x 10 meaning 67 cities x 10 days.
Explanation / Answer
Hello,
Please find the answer attached as under. Please give a thumbs up rating if you find the answer useful! Have a rocking day ahead!
Please run this code with your data files and see. All explanations are included in the comments
*** Matlab Code ***
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% differentials in temeprature
%%% Subtract high temps and low temps to get diff temepraure per day per
%%% city. Then find out the max and min of this array, to get
%%% MaxDifferentialInDayTemp and MinDifferentialInDayTemp
MaxDifferentialInDayTemp = max(abs(HighTemps - LowTemps));
MinDifferentialInDayTemp = max(abs(HighTemps - LowTemps));
%%% find out the differnce of high temps between consecutive days (N and
%%% N+1) and store them in DiffHighTemp. Then find out the max and min
%%% values to get MaxDifferentialBetweenDayTemp and MinDifferentialBetweenDayTemp
DiffHighTemp = zeros(67,9);
for i=1:9
DiffHighTemp(:,i) = HighTemps(:,i+1) - HighTemps(:,i);
end
MaxDifferentialBetweenDayTemp = max(abs(DiffHighTemp));
MinDifferentialBetweenDayTemp = min(abs(DiffHighTemp));
**** End of Code ***
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.