Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Adding a value to last value in Polynomials

Status
Not open for further replies.

oshaye3

Member level 3
Joined
Aug 4, 2010
Messages
62
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
london
Activity points
1,822
Dear all,
Thank you to all in this forum for giving all valuable knowledge to those really seeking for help. Please, if anyone could help me in this, I wanted to add 1 to the the last value of polynomials as seen below, but it was returning 1 vector.
The answer I want to get should be : 0.0931 0 -0.0931 0 1.0233

Please, your quick response is highly appreciated. I am writing software for plotting frequency response of chebyshev transfer function.


Enter the order of Chebyshev filter : 2

Enter the ripple factor of the passband : 0.1526

Cheb_P=ChebyshevPoly(n)
T_NB2=conv(Cheb_P,Cheb_P);
T_NB2EPS=T_NB2 * eibsln .^(2)
T_NB2EPS2= (T_NB2EPS(end)+1)

T_NB2EPS =

0.0931 0 -0.0931 0 0.0233

T_NB2EPS2 =

1.0233
 

Hi Oshaye3,

The problen in your code is that T_NB2EPS2 is defined as a scalar (whose value is the last component of T_NB2EPS plus one). You need a vector.

The last line, i.e.:
T_NB2EPS2= (T_NB2EPS(end)+1)

need to be reformulted. One way is:
T_NB2EPS2=T_NB2EPS;
T_NB2EPS2(end)=T_NB2EPS(end)+1;

Another way:
T_NB2EPS2= [T_NB2EPS(1:end-1), T_NB2EPS(end)+1];

The first one is better: it works equally for row or column vectors.
In the second way, for column vectors the "," should be replaced by ";".
Regards

Z
 
Thanks Zoro for this reply. It works as I want it to get the transfer function. Accurate! The result is pasted below with the code

code:

Enter the Filter response method You will use
Enter(c) for Chebyshev : c

You choose Chebyshev Approximation :
Enter (o) if You know the order & ripple factor or (d) for a filter design : o

Enter the order of Chebyshev filter : 2

Enter the ripple factor of the passband : 0.1526

Cheb_P =

2 0 -1


T_NB2EPS =

0.0931 0 -0.0931 0 0.0233


T_NB2EPS2 =

0.0931 0 -0.0931 0 1.0233


thepoles =

-1.3810 + 1.1863i
-1.3810 - 1.1863i
1.3810 + 1.1863i
1.3810 - 1.1863i


Transfer function:
1
---------------------
s^2 + 2.762 s + 3.314

---------- Post added at 20:02 ---------- Previous post was at 19:07 ----------

Zoro,
However, I am having two problems with this result. The first one is; it is not given me the transfer function of odd number order accurately. The second one is the swapping of roots of the polynomials . The swapping as you will observed should have been: -0.9660i - 0.2471 0.9660i - 0.2471 ...... you will see what I mean below in the results
I have posted the code below for you to see and the results. Cheers!

if (way == 'd')
ripples = input('\n Enter the Ripples value of the passband in dB Amax : ');
ws = input('\n Enter the normalized Rejection frequency ws: ');
att = input('\n Enter the Attenuation value at this frequency in dB Amin : ');
wp = input('\n Enter the frequency in wp : ');
po = ripples / 10;
po_att=att/10;
const = 10 .^ po;
const_att= 10.^po_att;
eibsln = sqrt((const - 1));
eibs_att=sqrt((const_att - 1));
n = (acosh((eibs_att)/(eibsln))/acosh(ws/wp));
n = ceil(n);
fprintf('\n The order of the filter is %d',n)
fprintf('\n The value of ripple factor is %d',eibsln)
elseif (way == 'o')
n = input('\n Enter the order of Chebyshev filter : ');
eibsln = input('\n Enter the ripple factor of the passband : ');
else
fprintf('\n Sorry! You entered a wrong choice');
end
% Get the poles

Cheb_P=ChebyshevPoly(n)
T_NB2=conv(Cheb_P,Cheb_P);
T_NB2EPS=T_NB2 * eibsln .^(2)
T_NB2EPS2=T_NB2EPS;
T_NB2EPS2(end)=T_NB2EPS(end)+1
% Get the poles
thepoles=roots(T_NB2EPS2)


hh = find (real(thepoles)< 0);
stpoles = thepoles(hh);
den = poly(stpoles);
den = real(den);
H = tf(1,den) % Transfer function

Results:

Enter the order of Chebyshev filter : 3

Enter the ripple factor of the passband : 0.5088

Cheb_P =

4 0 -3 0


T_NB2EPS =

4.1420 0 -6.2131 0 2.3299 0 0


T_NB2EPS2 =

4.1420 0 -6.2131 0 2.3299 0 1.0000


thepoles =

-0.9660 + 0.2471i
-0.9660 - 0.2471i
0.9660 + 0.2471i
0.9660 - 0.2471i
0.0000 + 0.4942i
0.0000 - 0.4942i


Transfer function:
1
----------------------
s^2 + 1.932 s + 0.9942


Hi Oshaye3,

The problen in your code is that T_NB2EPS2 is defined as a scalar (whose value is the last component of T_NB2EPS plus one). You need a vector.

The last line, i.e.:
T_NB2EPS2= (T_NB2EPS(end)+1)

need to be reformulted. One way is:
T_NB2EPS2=T_NB2EPS;
T_NB2EPS2(end)=T_NB2EPS(end)+1;

Another way:
T_NB2EPS2= [T_NB2EPS(1:end-1), T_NB2EPS(end)+1];

The first one is better: it works equally for row or column vectors.
In the second way, for column vectors the "," should be replaced by ";".
Regards

Z
 

Hi again,

If i'm not wrong, the characteristic you get in the polynomial whose coefficients are T_NB2EPS2 describes the amplitude characteristic (modulo squared) in the ω axis, i.e. in the imaginary axis of the s plane. So, the poles you get are not the poles of s but the poles of ω. Them must be rotated 90 degrees. Then, instead of

thepoles=roots(T_NB2EPS2)

you should put

thepolesOmega=roots(T_NB2EPS2);
thepoles=-j*thepolesOmega


As a consequence, real and imaginary parts are swapped (with a change of sign in one of them). The poles that in your case were purely imaginary become purely real, as expected. (For odd order, there is one real pole.)

Regards

Z
 
Thanks very much. I have been able to correct it. It is not swapped) Correct!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top