⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exam9.m

📁 线谱增强器
💻 M
字号:
clc;
clear all;
N = 2000;      %信号长度
F = 0.4;       %信号数字频率
A = 2;         %信号幅度
mu = 0.001;    %迭代步长
delta = 7;     %延时

n = 0 : 0.1 : 199.9;
s = A * cos(2 * pi * F * n);  %纯信号
d = s + 2.9 * randn(1, N);   %需要处理的信号
x = [zeros(1, delta), d(1: N - delta)];  %参考输入
figure(1);
x_c = 0 : N - 1;
subplot(2, 1, 1); plot(x_c, s); axis([0, N, -2, 2]); title('纯信号'); grid on;
subplot(2, 1, 2); plot(x_c, d); axis([0, N, -5, 5]); title('主输入'); grid on;

w = [1 1 1 1 1 1 1 1];      %LMS
for i = 1 : N - delta
    x1 = x(i : i + delta);
    y(i) = w * (x1');
    e(i) = d(i) - y(i);
    w = w + 2 * mu * e(i) * x1;
end

figure(2);
x_c = 1 : N - delta;
subplot(2, 1, 1); plot(x_c, e); axis([0, N - delta, -5, 5]); title('误差'); grid on;
subplot(2, 1, 2); plot(x_c, y); axis([0, N - delta, -5, 5]); title('输出信号'); grid on;

figure(3);
Y = fft(y(delta + 1 : N - delta), 512);
Pyy = Y.* conj(Y) / 512;
f = 1000 * (0: 256) / 512;
plot(f, Pyy(1: 257), 'r'); grid on; hold on;
D = fft(d, 512);
P = D.* conj(D) / 512;
f = 1000 * (0: 256) / 512;
plot(f, P(1: 257), 'b'); grid on;
legend('输出信号频谱', '输入信号频谱');

⌨️ 快捷键说明

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