One approach —
Uz = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/630240/household_power_consumption_2007.zip')
Uz = 1×1 cell array
{'household_power_consumption_2007.csv'}
T1 = readtable(Uz{1})
T1 = 521669×8 table
DateTime Global_active_power Global_reactive_power Voltage Global_intensity Sub_metering_1 Sub_metering_2 Sub_metering_3
____________________ ___________________ _____________________ _______ ________________ ______________ ______________ ______________
01-Jan-2007 00:00:00 2.58 0.136 241.97 10.6 0 0 0
01-Jan-2007 00:01:00 2.552 0.1 241.75 10.4 0 0 0
01-Jan-2007 00:02:00 2.55 0.1 241.64 10.4 0 0 0
01-Jan-2007 00:03:00 2.55 0.1 241.71 10.4 0 0 0
01-Jan-2007 00:04:00 2.554 0.1 241.98 10.4 0 0 0
01-Jan-2007 00:05:00 2.55 0.1 241.83 10.4 0 0 0
01-Jan-2007 00:06:00 2.534 0.096 241.07 10.4 0 0 0
01-Jan-2007 00:07:00 2.484 0 241.29 10.2 0 0 0
01-Jan-2007 00:08:00 2.468 0 241.23 10.2 0 0 0
01-Jan-2007 00:09:00 2.486 0 242.18 10.2 0 0 0
01-Jan-2007 00:10:00 2.492 0 242.46 10.2 0 0 0
01-Jan-2007 00:11:00 2.5 0 242.88 10.2 0 0 0
01-Jan-2007 00:12:00 2.494 0 242.57 10.2 0 0 0
01-Jan-2007 00:13:00 2.492 0 242.41 10.2 0 0 0
01-Jan-2007 00:14:00 2.48 0 241.81 10.2 0 0 0
01-Jan-2007 00:15:00 2.478 0 241.73 10.2 0 0 0
figure
scatter(T1.DateTime, T1.Global_active_power, '.')
grid
MeanHourlyConsumption = groupsummary(T1, 'DateTime', 'hourofday', 'mean', 'Global_active_power')
MeanHourlyConsumption = 24×3 table
hourofday_DateTime GroupCount mean_Global_active_power
__________________ __________ ________________________
0 21741 0.74066
1 21720 0.5522
2 21719 0.46917
3 21720 0.42062
4 21720 0.41507
5 21720 0.42935
6 21720 0.80487
7 21720 1.4331
8 21699 1.502
9 21719 1.3085
10 21720 1.2181
11 21719 1.1809
12 21717 1.1473
13 21720 1.0948
14 21756 1.0827
15 21780 1.0167
figure
scatter(MeanHourlyConsumption{:,1}, MeanHourlyConsumption{:,3}, 's')
grid
.