How to get max/min temp data from hourly data?

4 views (last 30 days)
Hi,
I have a dataset of hourly data for a 30+day period and have no clue where to start to get the daily min and max temperatures for each day of this period? Can anyone help me? Imagine that column1 is the day of year, column 2 is the time, and column 3 is the hourly temp.

Accepted Answer

Star Strider
Star Strider on 29 Jan 2015
Here is one approach:
D0 = datenum([2014 01 01 0 0 0]); % Start Date
Dv = D0 + [1/24:1/24:30]'; % Create Date Number Vector
Ds = datestr(Dv, 'dd.mm.yyyy HH'); % Convert To Date Strings
T = 10*sin([1/24:1/24:30]*2*pi*24)+15 + 2*randn(size(Dv')); % Temperature
Data30d = {Ds T'}; % Original Data
Tv30 = Data30d{2}; % Get Temperature Vector
Tv24 = reshape(Tv30, 24, []); % Reshape To 30 Days
Tmax = max(Tv24); % Get Daily Max
Tmin = min(Tv24); % Get Daily Min
I had to create the data, but this should work.
NOTE that the reshape function needs data for full 24-hour days for it (and my code) to work correctly.

More Answers (1)

JAG2024
JAG2024 on 29 Jan 2015
Thanks so much! Yup, I was able to modify it and get it to work. I ended up with something like this for multiple sites:
load IButtonsTemp14.txt
SQ4 = IButtonsTemp14(:,5);
TempSQ = SQ4(6:653); %Rows of data that I want
SQ27 = TempSQ; %For 27 day period
SQ24 = reshape(SQ27, 24, []); %Shape into 24-hr segments
SQmax = max(SQ24);
SQmin = min(SQ24);
I would also like to be able to use a for loop to do the same thing. But I can't seem to get it to work. If you have any thoughts about whether this is possible, I would love to hear it.
  3 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!