fig5_12.m

来自「数字信号处理Matlab演示文件,其中各个文件加放置了不同的matlab子文件」· M 代码 · 共 41 行

M
41
字号
echo on
% Example on 2nd order Butterworth LPF (digital & analogue)
% (gain plot)
% cut-off freq, wd = 628 rad/s
% sampling freq, ws = 5024 rad/s
echo off
%	Ms Oh
%	Revised BM July 98

clear
clf
colordef(1,'white')

wn=628/2512;			% normalised to half ws as in
				% Matlab requirement
order = 2;			% filter order

%	digital filter
[b,a] = butter(order,wn);
[h,w] = freqz(b,a,128);		% 128 pts for curve
mag = 20*log10(abs(h));
f = 5024*w/2/pi;		% normalise f scale

%	analogue filter
[z,p,k]=buttap(order);
[num,den]=zp2tf(z,p,k);
[numt,dent]=lp2lp(num,den,628);	% normalise to 628 rad/s
f2=0:2500/128:2500;
h2=freqs(numt,dent,f2);
mag2=20*log10(abs(h2));

plot(f,mag,f2,mag2,':');
axis( [ 0 2500 -100 0 ] );
xlabel('frequency (rad/s)')
ylabel('gain (dB)')

%gtext('analogue');
%gtext('bilinear');
%print a:fig5-12.eps -deps

⌨️ 快捷键说明

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