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.
任务1:
Calculate the 1-year moving average of total. Add this to the existing plot using point markers and a solid line. Repeat for the 2-year moving average.
解答1:
total12 = smoothdata(total,"movmean",12) hold on plot(dates,total12,".-") total24 = smoothdata(total,"movmean",24) plot(dates,total24,".-") hold off
结果1:
说明2:
The smoothdata function works column-wise on matrices. The sectorUsage variable contains usage data from three sectors in its three columns.
任务2:
Calculate the 2-year moving average of all the sectors in sectorUsage. Create a new plot of the result against dates. Use solid lines and no markers.
解答2:
sectorUsage24 = smoothdata(sectorUsage,"movmean",24) plot(dates,sectorUsage24,"-")
结果2:
附加练习:
The dates are spaced one calendar month apart. However, the months have different lengths, so the usage data is spaced slightly unevenly. To use the dates as sample points, you need to specify the window length as a duration.
nDur = years(2) useSp = smoothdata(sectorUsage,"movmean",... nDur,"SamplePoints",dates) plot(dates,useSp)
The data look almost identical, but a closer look at the difference reveals that they are not.
stem(dates,sectorUsage24-useSp) legend(sectors)
Here, sectorUsage24 represents the 2-year moving average of all the sectors in sectorUsage, but you may have given this variable from the last task a different name.
附加代码:
nDur = years(2) useSp = smoothdata(sectorUsage,"movmean",nDur,"SamplePoints",dates) plot(dates,useSp) stem(dates,sectorUsage24-useSp) legend(sectors)
附加结果:
笔记:附加部分的练习到底有何不同,”SamplePoints“到底该怎么用?
猜你喜欢
- 10天前(零碳中国·绿色投资蓝皮书)中国"零碳"差旅之路暨"绿色低碳酒店"标准研究项目成果发布会召开
- 10天前(三亚海棠湾君悦度假酒店)三亚海棠湾君悦酒店暑期夏令营悦趣海岛游招募中
- 10天前(哈弗h9优惠9万是真的吗)热浪来袭,哈弗H9超值补贴火热加码
- 10天前(艾美酒店连锁)艾美酒店全球夏日计划回归,联手Wishbone主厨推出创新冰饮
- 10天前(2025年“文化和自然遗产日”广东主会场活动举办)2025年“文化和自然遗产日”广东主会场活动举办
- 10天前(071 圣安东尼奥)秋季 圣安东尼奥交出了私藏活动清单
- 10天前(札幌小樽市)2024年暑期飞往北海道避暑吧!札幌小樽city walk路线推荐
- 10天前(纳米比亚旅游报价)纳米比亚旅游局2024年中国推介会圆满落幕
- 10天前(星级饭店的发展困境)星级饭店转型之路:从市场逻辑到行业实践的深度探索
- 10天前(泛舟诗海觅春迹什么意思)泛舟觅桃源,又一头部机构下场文旅赛道
网友评论
- 搜索
- 最新文章
- (2020广州车展哈弗)你的猛龙 独一无二 哈弗猛龙广州车展闪耀登场
- (哈弗新能源suv2019款)智能科技颠覆出行体验 哈弗重塑新能源越野SUV价值认知
- (2021款全新哈弗h5自动四驱报价)新哈弗H5再赴保障之旅,无惧冰雪护航哈弗全民电四驱挑战赛
- (海南航空现况怎样)用一场直播找到市场扩张新渠道,海南航空做对了什么?
- (visa jcb 日本)优惠面面俱到 JCB信用卡邀您畅玩日本冰雪季
- (第三届“堡里有年味·回村过大年”民俗花灯会活动)第三届“堡里有年味·回村过大年”民俗花灯会活动
- (展示非遗魅力 长安启源助力铜梁龙舞出征)展示非遗魅力 长安启源助力铜梁龙舞出征
- (阿斯塔纳航空公司)阿斯塔纳航空机队飞机数量增至50架
- (北京香港航班动态查询)香港快运航空北京大兴新航线今日首航
- (我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉)我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉
- 热门文章