How to get max/min temp data from hourly data?
4 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
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.
0 Comments
More Answers (1)
See Also
Categories
Find more on String in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!