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

📄 ex0821.m

📁 数字信号处理(机械工业出版社)的源码
💻 M
字号:
% Chapter 08: Example 8.21 Design a filter
Fs=1000;;
t=0:1/Fs:2; % t is time(2s)
x=sin(2*pi*80*t)+2*sin(2*pi*140*t);
xn=x+randn(size(t));
figure(1)
n=100;  %  filter's length
f=[0 0.13 0.15 0.17 0.19 0.25 0.27 0.29 0.31 1];
m=[0 0 1 1 0 0 1 1 0 0];
b=firls(n,f,m);
[h,w]=freqz(b,1,512,2);
plot(w,abs(h)); grid on
xlabel('Normalized Frequency'); ylabel('magnitude(dB)');
pause
figure(2)
xo=filter(b,1,xn);
% plot
nn=500:750; tt=nn/Fs;
subplot(311); plot(tt,x(nn)); grid on
ylabel('Original signal')
subplot(312); plot(tt,xn(nn)); grid on
ylabel('Signal with noise')
subplot(313); plot(tt,xo(nn)); grid on
ylabel('filtered signal')
xlabel('Time(s)')

⌨️ 快捷键说明

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