📄 mmse.m
字号:
%
%主函数
%XS是周期性信号
%XN是干扰信号
%
clear
t=0:0.5:1000;
xs=(5*sin(0.05*t))';
figure(1);
subplot(211);
plot(t,xs);grid;
ylabel('幅度');
title('\it{输入周期性信号}');
xn=(sqrt(0.5)*randn(1,length(t)))';
subplot(212);
plot(t,xn);grid;
ylabel('幅度');
xlabel('时间');
title('\it{随机噪声信号}');
d=xs;
x=xs+xn;
%u=2e-3;
N=10;
w=(zeros(1,N))';
M=length(x);
y=(zeros(1,M))';
e=(zeros(1,M))';
sum1=zeros(N,N);
sum2=zeros(N,1);
for n=1:M-9
x1=x(n:n+9);
y(n)=w'*x1;
juzhen=x1*x1';
sum1=sum1+juzhen;
rxx=sum1/(n);
x2=x1*conj(d(n));
sum2=sum2+x2;
rxd=sum2/(n);
w=pinv(rxx)*rxd;
e(n)=d(n)-y(n);
end
figure(2);
%subplot(313)
%plot(t,y);
plot(t,d,t,y,t,e);grid;
axis([0,1000,-10,10]);grid;
ylabel('幅度');
xlabel('时间');
figure(3);
%subplot(313)
plot(t,x);grid;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -