clear
close all
% Digital Filter Specifications:
wp = 0.2*pi; % digital Passband freq in rad
ws = 0.3*pi; % digital Stopband freq in rad
Rp = 1; % Passband ripple in dB
As = 50; % Stopband attenuation in dB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% T = 1; %Set T=1
% OmegaP = (2/T)*tan(wp/2); %Prewarp Prototype Passband freq
% OmegaS = (2/T)*tan(ws/2); %Prewarp Prototype Stopband freq
% N =ceil((log10((10^(Rp/10)-1)/(10^(As/10)-1)))/(2*log10(OmegaP/OmegaS)));
% OmegaC = OmegaP/((10^(Rp/10)-1)^(1/(2*N))); %Analog BW prototype cutoff
% wn = 2*atan((OmegaC*T)/2); %Digital BW cutoff freq
% wn = wn/pi;
%[N,wn] = buttord(wp/pi,ws/pi,Rp,As);
% [b,a] = butter(N,wn);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% T = 1; %Set T=1
% OmegaP = (2/T)*tan(wp/2); %Prewarp Prototype Passband freq
% OmegaS = (2/T)*tan(ws/2); %Prewarp Prototype Stopband freq
% ep = sqrt(10^(Rp/10)-1); %Passband Ripple Factor
% A = 10^(As/20); %Stopband Attenuation Factor
% OmegaR = OmegaS/OmegaP; %Analog Prototype Transition Ratio
% g = sqrt(A*A-1)/ep; %Analog Prototype Intermediate cal.
% N = ceil(log10(g+sqrt(g*g-1))/log10(OmegaR+sqrt(OmegaR*OmegaR-1)));
%wn = wp/pi;
%wn = ws/pi;
%[N,wn] = cheb1ord(wp/pi,ws/pi,Rp,As);
%[b,a]=cheby1(N,Rp,wn);
%[N,wn] = cheb2ord(wp/pi,ws/pi,Rp,As);
%[b,a]=cheby2(N,As,wn);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% T = 1; %Set T=1
% OmegaP = (2/T)*tan(wp/2); %Prewarp Prototype Passband freq
% OmegaS = (2/T)*tan(ws/2); %Prewarp Prototype Stopband freq
% ep = sqrt(10^(Rp/10)-1); A = 10^(As/20);
% OmegaC = wp; k = wp/ws; k1 = ep/sqrt(A*A-1);
% capk = ellipke([k.^2 1-k.^2]); % Version 4.0 code
% capk1 = ellipke([(k1 .^2) 1-(k1 .^2)]); % Version 4.0 code
% N = ceil(capk(1)*capk1(2)/(capk(2)*capk1(1)));
%wn = wp/pi; %Digital Passband freq in pi units
[N,wn] = ellipord(ws/pi,wp/pi,Rp,As);
[b,a]=ellip(N,Rp,As,wn,'high');
[hr,w] = freqz(b,a,1000);
figure;
plot(w/pi,db(hr),'r')
grid on
评论0