Jacqueline asked . 2021-03-10

Why do I receive two different responses when I try to discretize the same analog filter using the ELLIP

Why do I receive two different responses when I try to discretize the same analog filter using the ELLIP and ELLIPAP functions in  Signal Processing Toolbox 6.12 (R2009b)?

 

I am trying to discretize an analog filter using the ELLIP function with the ‘s’ parameter and the ELLIPAP function. The specifications of the analog filter are the same in both the cases. In the case of using the ELLIP function with the ‘s’ argument, I discretize the filter using bilinear transform as shown in the code below.
 
 

 

Fs = 2e9; 

FN = Fs/2;

fp = 0.4*FN; 

fs = 0.42*FN;

wp = fp*2*pi; 

ws = fs*2*pi;

Ap = 1.2; 

As = 100;

% Calculate filter coefficients and frequency responses

[N, wc] = ellipord(wp, ws, Ap, As, 's'); 

[B, A] = ellip(N, Ap, As, wc, 's');

[bBZT, aBZT] = bilinear(B, A, Fs); 

[Ha, wa] = freqs(B, A);

figure;

plot(wa/(2*pi), 20*log10(abs(Ha)))  

[HB, fB]=freqz(bBZT, aBZT, 512, Fs);

hold on

plot(fB, 20*log10(abs(HB)), 'r'); 

legend('Analog Response', 'Digital reponse');
While using the ELLIPAP function, I design the analog prototype first, do the frequency transformation to the specific range and then discretize it, also using bilinear transformation as shown in the code below.
 
 
Fs = 2e9; 

FN = Fs/2;

fp = 0.4*FN; 

fs = 0.42*FN;

wp = fp*2*pi;

ws = fs*2*pi;

Ap = 1.2; 

As = 100;

% Calculate filter coefficients and frequency responses

[N, wc] = ellipord(wp, ws, Ap, As,'s'); 

[z, p, k] = ellipap(N, Ap, As); 

[A, B, C, D] = zp2ss(z, p, k); 

[At, Bt, Ct, Dt] = lp2lp(A, B, C, D, wc); 

[Bs, As] = ss2tf(At, Bt, Ct, Dt);

[Ad, Bd, Cd, Dd] = bilinear(At, Bt, Ct, Dt, Fs);

[bd, ad] = ss2tf(Ad, Bd, Cd, Dd);

[Ha, wa]=freqs(Bs, As);

figure; 

plot(wa/(2*pi), 20*log10(abs(Ha))) 

hold on

[HB, fB]=freqz(bd, ad, 512, Fs);

plot(fB, 20*log10(abs(HB)), 'r'); 

legend('Analog Response(using Analog prototype)', 'Digital response (using Analog prototype)');
However, I observe different responses for the discretized filters generated from the above code.

matlab , signal , signal processing , filter design

Expert Answer

John Williams answered . 2024-05-17 21:39:57

The two approaches used to discretize the analog filter are theoretically equivalent. However, they present different numerical challenges.
 
In the script that uses ELLIP, a transfer function is generated, which should almost always be avoided if one wishes to obtain a numerically robust filter. The modified script below will yield the same filter whether you use ELLIP or ELLIPAP:
Fs=2e9; 

FN=Fs/2; % Sampling and Nyquist frequencies

fp=0.4*FN; 

fs=0.42*FN; %Passband and Stopband frequencies

wp=fp*2*pi; 

ws=fs*2*pi; %Passband and Stopband edge frequencies

Ap=1.2; 

As=100; % Passband and Stopband attenuation

% Calculate filter coefficients and frequency responses

[N, wc]=ellipord(wp, ws, Ap, As, 's'); % analog filter

%--------------------------------------------------------------------------

% Design using ELLIP for the analog prototype

%--------------------------------------------------------------------------

[A, B, C, D] = ellip(N, Ap, As, wc, 's');

[Ad, Bd, Cd, Dd] = bilinear(A, B, C, D, Fs);

[sos, g] = ss2sos(Ad, Bd, Cd, Dd);

hd1 = dfilt.df2sos(sos, g);

%--------------------------------------------------------------------------

% Design using ELLIPAP for the analog prototype

%--------------------------------------------------------------------------

[z, p, k] = ellipap(N, Ap, As);

[A, B, C, D] = zp2ss(z, p, k);

[At, Bt, Ct, Dt] = lp2lp(A, B, C, D, wc);

[Bs, As] = ss2tf(At, Bt, Ct, Dt);

[Ad, Bd, Cd, Dd] = bilinear(At, Bt, Ct, Dt, Fs);

[sos, g] = ss2sos(Ad, Bd, Cd, Dd);

hd2 = dfilt.df2sos(sos, g);

fvtool(hd1, hd2)


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.