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“到底该怎么用?
猜你喜欢
- 14天前(临沂 凯悦)临沂第一家凯悦嘉轩酒店开幕迎宾
- 14天前(安徽民航君澜大饭店装饰设计招标)集东方文化气息,品徽派隽美风韵----安徽民航君澜大饭店静待绽放
- 14天前(甘州区文化旅游局)2025甘津文旅资源对接推介会在兰州举办
- 14天前(河南省文旅大会精神)2025河南省文化旅游发展大会新闻发布会在郑州召开
- 14天前(云南南博会展馆)旅居云南馆亮相第9届南博会
- 14天前(新西兰航空官方网站)新西兰航空85周年焕新启航 全方位客舱升级,飞「悦」快意时光
- 14天前(世茂海峡大厦多高)巴西地产高管齐聚厦门世茂海峡大厦 共探超高层建筑锻造经验
- 14天前(2025年安徽省“百场黄梅唱响百家景区”示范展示启动)2025年安徽省“百场黄梅唱响百家景区”示范展示启动
- 14天前(大黄山景区高质量发展联盟成立多少年)大黄山景区高质量发展联盟成立
- 14天前(阿斯塔纳航空属于哪个联盟)阿斯塔纳航空荣获Skytrax世界航空公司大奖,将继续助力中哈交流往来
网友评论
- 搜索
- 最新文章
- (2020广州车展哈弗)你的猛龙 独一无二 哈弗猛龙广州车展闪耀登场
- (哈弗新能源suv2019款)智能科技颠覆出行体验 哈弗重塑新能源越野SUV价值认知
- (2021款全新哈弗h5自动四驱报价)新哈弗H5再赴保障之旅,无惧冰雪护航哈弗全民电四驱挑战赛
- (海南航空现况怎样)用一场直播找到市场扩张新渠道,海南航空做对了什么?
- (visa jcb 日本)优惠面面俱到 JCB信用卡邀您畅玩日本冰雪季
- (第三届“堡里有年味·回村过大年”民俗花灯会活动)第三届“堡里有年味·回村过大年”民俗花灯会活动
- (展示非遗魅力 长安启源助力铜梁龙舞出征)展示非遗魅力 长安启源助力铜梁龙舞出征
- (阿斯塔纳航空公司)阿斯塔纳航空机队飞机数量增至50架
- (北京香港航班动态查询)香港快运航空北京大兴新航线今日首航
- (我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉)我在港航“呵护”飞机 每一次安全着陆就是最好的荣誉
- 热门文章