我不知道为什么
filter
函数似乎输出了与
smoothdata
功能。它们都应该实现
5
使用平滑
移动平均
. 精通这些功能的人能解释发生了什么吗?
这是>
link
平滑数据
(对于额外的谜题,
smooth
功能,这也不一样):
% from documentation
t = linspace(-pi,pi,100);
rng default %initialize random number generator
x = sin(t) + 0.25*rand(size(t));
windowSize = 5;
b = (1/windowSize)*ones(1,windowSize);
a = 1;
y = filter(b,a,x);
%this is added for this example, you need >Matlab 2017a to run this
y2=smoothdata(x,'movmean',windowSize)
%y3=smooth(x,100); %bug in the code (obsolete)
y3=smooth(x,windowSize);
%now plot data
figure;
plot(t,x)
hold on
plot(t,y)
plot(t,y2)
plot(t,y3)
legend('Input Data&#