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

📄 fig.m

📁 很多matlab的源代码
💻 M
字号:
%把数字滤波器的频率特征转换成模拟滤波器的频率特征
Wp=2*pi*30;
Ws=2*pi*40;
Rp=0.5; Rs=40; Fs=500;
figure('position',[50 50 700 500],'name','滤波器信号处理');
te1=uicontrol('style','text',...
        'position',[10 460 60 20],...
        'FontSize',12,...
        'HorizontalAlignment','left',...
        'BackGroundColor',[0.8 0.8 0.8],...
        'string','抽样频率:');
ed1=uicontrol('style','edit',...
        'FontSize',12,...
        'position',[80 460 40 20]);
te2=uicontrol('style','text',...
        'position',[140 460 60 20],...
        'FontSize',12,...
        'HorizontalAlignment','left',...
        'BackGroundColor',[0.8 0.8 0.8],...
        'string','最大衰减:');
ed2=uicontrol('style','edit',...
        'FontSize',12,...
        'position',[200 460 60 20]);
te3=uicontrol('style','text',...
        'position',[270 460 60 20],...
        'FontSize',12,...
        'HorizontalAlignment','left',...
        'BackGroundColor',[0.8 0.8 0.8],...
        'string','最小衰减:');
ed3=uicontrol('style','edit',...
        'FontSize',12,...
        'position',[330 460 60 20]);
run_button=uicontrol('style','push',...
        'position',[160 380 80 20],...
        'string','测试',...
        'FontSize',12,...
        'callback',[...
            'set(Rp,get(ed2,''string''));',...
           'set(Rs,get(ed3,''string''));',...
            'set(Fs,get(ed1,''string''));']);
empty_string='';
clear_button=uicontrol('style','push',...
        'position',[300 380 80 20],...
        'string','重新设置',...
        'FontSize',12,...
        'callback',['set(ed1,''string'',empty_string)',...
                    'set(ed2,''string'',empty_string)',...
                    'set(ed3,''string'',empty_string)']);

%选择滤波器的阶数
[N,Wn]=buttord(Wp,Ws,Rp,Rs,'s');
%创建Butterworth低通滤波器原型
[z,p,k]=buttap(N);
%从零极点形式转换成状态方程形式
[A,B,C,D]=zp2ss(z,p,k);
%实现低通到高通滤波器类型的转换
[At,Bt,Ct,Dt]=lp2hp(A,B,C,D,Wn);
%采用双线性变换法实现从模拟低通到数字高通滤波器的转换
[b,a]=ss2tf(At,Bt,Ct,Dt);
[b1,a1]=bilinear(b,a,Fs);
%绘出频率响应曲线
subplot(3,1,2);
[h,w]=freqz(b1,a1);
plot(w*Fs/(2*pi),abs(h));
grid;
xlabel('频率(Hz)');
ylabel('幅值');
title('Highpass digital filter');
subplot(3,1,3);
plot(w*Fs/(2*pi),20*log10(abs(h)));
grid;
xlabel('频率(Hz)');
ylabel('幅值(dB)');
title('Highpass digital filter');

⌨️ 快捷键说明

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