Plotting Day and Time from csv file
古いコメントを表示
I am attempting to plot hourly power data from the first day of each month for all 24 hours of that day for one year (288 date/time points). Ideally, it should be grouped into twelve curves, one curve for each day. I extracted the date-time information from a .csv file and plotted my output power data against these date-time values. Unfortunately, MATLAB automatically filled in all the days in between the first day of each month with zeros on my graph, so I have twelve sharp, unreadable peaks instead of twelve curves where I can read the data at each hour.
The code I used to plot is attached, as well as the hourlyTempWindData.csv, Q_Total is a 1x288 double that's calculated by the rest of my code (which is very long), so I've included a random number array instead. I want my graph to look like the second one (one day with a data point at each hour) instead of the first (unreadable peak with flat space in between).
Also, is there anything I can do to stop the orange warning from showing up after I use readtable to get the data from the csv? It isn't interfering with my code running, it's just annoying.
%Import radiation and weather data sheets, and set variables for each
%column, then transpose values to a row vector
hourlyData = readtable("hourlyTempWindData.csv", 'VariableNamingRule','preserve')
dates = datetime(table2array(hourlyData(:,1)));
Q_Total = randi(50, [1 288]);
%Graph daily energy losses/gains against date and hour, results in 12 sharp
%peaks with flat space between
figure(1)
hold off
grid on
plot(dates, Q_Total)
title('Hourly Energy Needs for Greenhouse');
xlabel('Date and Time');
ylabel('Q (Btu/h)');
%Graph daily energy losses/gains, results in 12 curves (when using actual
%data, not randi)
figure(2)
hold off
grid on
plot(Q_Total);
title('Hourly Energy Needs for Greenhouse');
xlabel('Date and Time');
ylabel('Q (Btu/h)');
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



