ls.m

来自「这个包中包含学习最小均方滤波的一个例子及其和其它滤波方法的一些比较。」· M 代码 · 共 31 行

M
31
字号
clear,close all;
N=100;
M=2;
period=[0:N-1];
x=sin(2*pi*0.02*period);
figure;%作图1的第一子图
subplot(2,1,1);
plot(x);
grid;
title('standard singal');
period1=[0,0:N-2];
x1=sin(2*pi*0.02*period1);
noise=0.05*randn(1,N);
xn=x+noise;
subplot(2,1,2);%作图1的第二子图
plot(xn);
grid;
title('standard singal with noise var=0.05');
y=0.5*x+0.5*x1+noise;
[R,d]=lsmatvec('prew',x',M,y');
cls=R\d;
Y=filter(1,cls,x);
figure;%作图2的第一子图
subplot(2,1,1);
plot(0:N-1,Y,'.',0:N-1,x,'k');
grid;
title('预测信号与实际信号的比较');
legend('预测信号,实际信号');


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?