Matlab自适应均线_matlab – 计算移动平均线

本文介绍了如何利用MATLAB的filter函数计算一个16元素向量的滑动平均,窗口大小为5。此外,还展示了smooth函数在处理数据平滑时的应用,包括使用loess和rloess方法,以及如何通过改变span值来调整平滑程度。
摘要由CSDN通过智能技术生成

还有两种选择:

来自doc:

You can use filter to find a running average without using a for loop.

This example finds the running average of a 16-element vector, using a

window size of 5.

data = [1:0.2:4]'; %'

windowSize = 5;

filter(ones(1,windowSize)/windowSize,1,data)

2)smooth作为曲线拟合工具箱的一部分(在大多数情况下可用)

来自doc:

yy = smooth(y) smooths the data in the column vector y using a moving

average filter. Results are returned in the column vector yy. The

default span for the moving average is 5.

%// Create noisy data with outliers:

x = 15*rand(150,1);

y = sin(x) + 0.5*(rand(size(x))-0.5);

y(ceil(length(x)*rand(2,1))) = 3;

%// Smooth the data using the loess and rloess methods with a span of 10%:

yy1 = smooth(x,y,0.1,'loess');

yy2 = smooth(x,y,0.1,'rloess');

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值