Plotting data from a table with a datetime in it, monthly records
Ältere Kommentare anzeigen
I want to plot monthly records for my weather station. My weather station outputs a csv file that looks like this:
"Timestamp","Outdoor Temperature","Outdoor Humidity","Dew Point","Heat Index","Wind Chill","Barometric Pressure","Rain","Wind Speed","Wind Average","Peak Wind","Wind Direction","Indoor Temperature","Indoor Humidity"
"8/7/2016 8:12:00 PM","75.7","74","66","77","76","29.85481","27.41","0","0","3.728227","180","83.4","53"
"8/7/2016 8:24:00 PM","74.8","71","65","76","75","29.88434","27.41","0","0","3.728227","180","84","55"
"8/7/2016 8:36:00 PM","73.9","71","63","75","74","29.88434","27.41","0","0","1.864114","202.5","84.2","54"
"8/7/2016 8:48:00 PM","73.2","72","63","74","73","29.88434","27.41","0","0","1.242742","180","84.2","52"
"8/7/2016 9:00:00 PM","72.3","73","62","73","72","1012","27.41","0","0","0","180","84.2","52"
"8/7/2016 9:12:00 PM","71.6","74","62","73","72","1012","27.41","0","0","0","157.5","84","52"
"8/7/2016 9:24:00 PM","70.9","76","63","72","71","1013","27.41","0","0","0","180","84.2","52"
My current code is as follows:
%%Graph daily, monthly weather maps, and show records for each month
weather = xlsread('acuriteweather.xlsx');
getdate = readtable('acuriteweather.csv');
% %%Change table values to categorical array
getdate.Timestamp = categorical(getdate.Timestamp);
% Pull out relevant variables to be graphed, daily and monthly
date_array = datetime(cellstr(getdate.Timestamp),'InputFormat','MM/dd/yyyy HH:mm');
temperature = weather(:,1);
RH = weather(:,2);
dew_point = weather(:,3);
for date_array.Month == 12
maxtemp = max(temperature);
avgtemp = mean(temperature);
mintemp = min(temperature);
maxRH = max(RH);
averageRH = mean(RH);
minRH = min(RH);
maxDP = max(dew_point);
avgDP = mean(dew_point);
minDP = min(dew_point);
end
% Plot monthly records
monthly = [maxtemp avgtemp mintemp; maxDP avgDP minDP; maxRH averageRH minRH];
values = {'Temperature ºF', 'Dew Point ºF', 'Relative Humidity'};
bar(monthly)
set(gca, 'YGrid', 'on', 'XGrid', 'off')
yticks([-10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100])
title('Records for Month')
set(gca,'xticklabel',values)
I am only able to get my variables for all of my data, which spans August 2016 to September 2017. I cannot figure out how to get the maximum, average, and minimum for each month for respectively.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Weather and Atmospheric Science finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
