MATLAB Fundamentals>Common Data Analysis Techniques>Smoothing Data> (3/5) Smoothing Electricity Data
数据准备:This code sets up the activity.
load electricityData
whos
total = usage(:,end);
sectorUsage = usage(:,1:3);
sectors = sectors(1:3);
plot(dates,total,".-")
说明1:
The table edata
contains monthly electricity usage, in MWh, for the U.S., separated by sector. The matrix sectorUsage
contains the consumption for three sectors (residential, commercial, and industrial). The vector total
contains the total consumption. The months are stored in the datetime vector dates
.
You can smooth the data using the smooth data function.
dataSm = smoothdata(data,"movmean",n)
When the data are evenly sampled, you do not need to specify the sample points.