关于用 MATLAB 设计对信号进行频谱分析和滤波处理的程序
完整的程序
%写上标题
%设计低通滤波器:
[N,Wc]=buttord()
%估算得到 Butterworth 低通滤波器的最小阶数 N 和 3dB 截止频率 Wc
[a,b]=butter(N,Wc); %设计 Butterworth 低通滤波器
[h,f]=freqz(); %求数字低通滤波器的频率响应
figure(2); % 打开窗口 2
subplot(221); %图形显示分割窗口
plot(f,abs(h)); %绘制 Butterworth 低通滤波器的幅频响应图
title(巴氏低通滤波器'');
grid; %绘制带网格的图像
sf=filter(a,b,s); %叠加函数 S 经过低通滤波器以后的新函数
subplot(222);
plot(t,sf); %绘制叠加函数 S 经过低通滤波器以后的时域图形
xlabel('时间 (seconds)');
ylabel('时间按幅度');
SF=fft(sf,256); %对叠加函数 S 经过低通滤波器以后的新函数进行 256 点的基
—2 快速傅立叶变换
w= %新信号角频率
subplot(223);
plot()); %绘制叠加函数 S 经过低通滤波器以后的频谱图
title('低通滤波后的频谱图');
%设计高通滤波器
[N,Wc]=buttord()
%估算得到 Butterworth 高通滤波器的最小阶数 N 和 3dB 截止频率 Wc
[a,b]=butter(N,Wc,'high'); %设计 Butterworth 高通滤波器
[h,f]=freqz(); %求数字高通滤波器的频率响应
figure(3);
subplot(221);
plot()); %绘制 Butterworth 高通滤波器的幅频响应图
title('巴氏高通滤波器');
grid; %绘制带网格的图像
sf=filter(); %叠加函数 S 经过高通滤波器以后的新函数
subplot(222);
plot(t,sf); ;%绘制叠加函数 S 经过高通滤波器以后的时域图形
xlabel('Time(seconds)');
ylabel('Time waveform');
w; %新信号角频率
subplot(223);
plot()); %绘制叠加函数 S 经过高通滤波器以后的频谱图
title('高通滤波后的频谱图');
%设计带通滤波器
评论1