Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with my matlab code. I\'m basically trying to find the poles of the bu

ID: 2085255 • Letter: N

Question

Need help with my matlab code. I'm basically trying to find the poles of the butterworth low pass filter without using the butter() function.

For my a vector it has to be a=[1 sqrt(2) 1]; but instead i'm getting a=3.4142 . Can someone help me tell me why code it's not giving me the correct a vector?

Thank you

clc
clear all
w=logspace(-1,4,1000);
%p represents poles of the filter
p0=exp(1*i*pi/4);
p1=exp(1*i*3*pi/4);
p2=exp(1*i*5*pi/4);
p3=exp(1*i*7*pi/4);
%real function gets the real poles
real(p0);
real(p1);
real(p2);
real(p3);

% i used p1 and p2 because we need the poles in left hand plane which are negative

conv([1-p1],[1-p2]);
a=real(conv([1-p1],[1-p2]));%a needs to be [1 sqrt(2) 1]
b=[1];
freqs(b,a,w)

Explanation / Answer

Ans)

I have corrected the code ,the error is you missed the space when defining a vector i.e [1 -p1] instead of [1-p1]

corrected code here

==============

clc
clear all
w=logspace(-1,4,1000);
%p represents poles of the filter
p0=exp(1*1i*pi/4);
p1=exp(1*1i*3*pi/4);
p2=exp(1*1i*5*pi/4);
p3=exp(1*1i*7*pi/4);
%real function gets the real poles
real(p0);
real(p1);
real(p2);
real(p3);
% i used p1 and p2 because we need the poles in left hand plane which are negative
conv([1 -p1],[1 -p2]);
a=real(conv([1 -p1],[1 -p2]));%a needs to be [1 sqrt(2) 1]
a
b=[1];
freqs(b,a,w)

=============================

Result in command window

a =

1.0000 1.4142 1.0000

===========

I guess that is the answer you anticipated as in question

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote