100% found this document useful (1 vote)
827 views

Matlab Code For Implementation of Routh Harwitz Table

The document contains code to generate the Routh-Hurwitz table for a polynomial in Matlab. It asks the user to input the degree and coefficients of the polynomial. It then constructs the table and analyzes the first column to determine the number of sign changes, which indicates the number of poles in the right half plane. In the examples provided, the 20th degree polynomial from question 1 has 10 poles in the RHP, and the 20th degree polynomial from question 2 has 8 poles in the RHP.

Uploaded by

waqasahmadz
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
827 views

Matlab Code For Implementation of Routh Harwitz Table

The document contains code to generate the Routh-Hurwitz table for a polynomial in Matlab. It asks the user to input the degree and coefficients of the polynomial. It then constructs the table and analyzes the first column to determine the number of sign changes, which indicates the number of poles in the right half plane. In the examples provided, the 20th degree polynomial from question 1 has 10 poles in the RHP, and the 20th degree polynomial from question 2 has 8 poles in the RHP.

Uploaded by

waqasahmadz
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Matlab-code-for-implementation-of-routhharwitz-tabletable

Question No.:01
Construct the Routh Hurwitz Table for given Polynomial (ascending order of degree) using Matlab

1+143s+(143s) 2 +(143s)3 +(143s) 4 +(143s)5 +(143s)6 +(143s)7 +(143s)8 +(143s)9 + (143s)10


+ (143s)11 +(143s)14 +(143s)15 +(143s)16 +(143s)17 +(143s)18 +(143s)19 +(143s) 20

MATLAB M-FILE
clc;clear all; A=0; n=input('Enter the degree of polynomial::::');
c=input('Enter Coefficients of polynomial in ascending order::::');
c=fliplr(c);
%%flip the row vector to arrange in descending order
m=ceil((n+1)/2);
%%The no. of columns of Table
%%Enter first 2 rows of R-H Table
for j=1:m
for i=1:2
A(i,j)=c(2*j+i-2);
if (2*j+i-2)==length(c)
c(1,2*j+i-1)=0;
end
end
end
m=m-1;
for i=3:n+1
if A(i-1,1)==0
if A(i-1,:)==0
%%Check for full row to be zero
PP=A(i-2,:); g=n-i+4;EP=0;
disp(['Zero row is found at S^' int2str(g-2)]);
for q=1:2:g
EP(q)=PP((q+1)/2);
end
if length(EP)<g
EP(g)=0;
end
der_EP=polyder(EP);
der=der_EP(1:2:length(der_EP));
A(i-1,:)=[der zeros(1,m+1-length(der))];
else
A(i-1,1)=1e-3;
%%Change the first column entry
end
end
for j=1:m
A(i,j)= -det([A(i-2,1),A(i-2,j+1);A(i-1,1),A(i-1,j+1)])/A(i-1,1);
end
end
disp('Routh Hurwitz Table is::::'),disp(A)
c1=A(:,1)', c1(c1>1)=1;c1(c1<1)=0; %%%Access Contents of 1st column
N=length(find(diff(c1)~=0));
disp(['No of sign changes::::' int2str(N)]);

COMMAND WINDOW

Enter the degree of polynomial::::20


Enter Coefficients of polynomial in ascending order::::[1 143 143^2 143^3
143^4 143^5 143^6 143^7 143^8 143^9 143^10 143^11 143^12 143^13 143^14
143^15 143^16 143^17 143^18 143^19 143^20];
No of sign changes::::10
**Table was also displayed on Command Window but I have shown it from
workspace.

WorkSpace

Question No.:02
Generate the Routh Hurwitz Table for given Polynomial (in descending order of degree of
polynomial) using MATLAB:
s 20 +34s19 +12s18 +23s17 +6s16 +78s15 +6s14 s11 s10 +88s 9 +7s8 +4s 7 +3s 6 +2s5 +2s4 +5s3 +4s 2 +3s+1

MATLAB M-FILE

clc;clear all;c=0;A=0;
n=input('Enter the degree of polynomial::::');
c=input('Enter Coefficients of polynomial in descending order::::');
m=ceil((n+1)/2);
for j=1:m
for i=1:2
A(i,j)=c(2*j+i-2);
if (2*j+i-2)==length(c)
c(1,2*j+i-1)=0;
end
end
end
m=m-1;
for i=3:n+1
if A(i-1,1)==0
if A(i-1,:)==0
PP=A(i-2,:);g=n-i+4;EP=0;
disp(['Zero row is found at S^' int2str(g-2)]);
for q=1:2:g
EP(q)=PP((q+1)/2);
end
if length(EP)<g
EP(g)=0;
end

der_EP=polyder(EP);
der=der_EP(1:2:length(der_EP));
A(i-1,:)=[der zeros(1,m+1-length(der))];
else

A(i-1,1)=1e-3;

end

end
for j=1:m
A(i,j)= -det([A(i-2,1),A(i-2,j+1);A(i-1,1),A(i-1,j+1)])/A(i-1,1);
end

end
disp('Routh Hurwitz Table is::::'),disp(A)
c1=A(:,1)', c1(c1>1)=1;c1(c1<1)=0;
N=length(find(diff(c1)~=0));
disp(['No of sign changes::::' int2str(N)]);

COMMAND WINDOW
Enter the degree of polynomial::::20
Enter Coefficients of polynomial in descending order::::[1 34 12 23 6 78
6 0 0 -1 -1 88 7 4 3 2 2 5 4 3 1]
Routh Hurwitz Table is::::
Columns 1 through 7
1.0000
12.0000
6.0000
6.0000
0
-1.0000
7.0000
34.0000
23.0000
78.0000
0
-1.0000
88.0000
4.0000
11.3235
3.7059
6.0000
0.0294
-3.5882
6.8824
2.9412
11.8727
59.9844
-0.0883
9.7740
67.3351
-4.8312
-3.5636
-53.5038
6.0842
-9.2925 -67.8086
11.4900
6.3400
8.2864
61.3345
-2.1504
-5.2730
69.8848
-3.4243
-1.7249
-5.8769
4.2084 -13.8923
-6.8461
8.5029
4.8353
3.1598
4.1055
200.3194
94.5046 -54.0393 -73.8957 -47.7769 -65.7123 -14.3550
-15.8777
-5.7109
10.0554
5.8391
4.5403
4.4071
1.0000
22.4540
72.8235
-0.2278
9.5059 -10.1101
-1.7385
0
45.7841
9.8943
12.5608
-2.6087
3.1778
1.0000
0
67.9710
-6.3880
10.7853 -11.6686
-2.2290
0
0
14.1972
5.2961
5.2510
4.6792
1.0000
0
0
-31.7438 -14.3548 -34.0708
-7.0166
0
0
0
-1.1240
-9.9869
1.5410
1.0000
0
0
0
267.6909 -77.5920 -35.2582
0
0
0
0
-10.3127
1.3930
1.0000
0
0
0
0
-41.4337
-9.3008
0
0
0
0
0
3.7079
1.0000
0
0
0
0
0
1.8736
0
0
0
0
0
0
1.0000
0
0
0
0
0
0
Columns 8 through 11
3.0000
2.0000
4.0000
1.0000
2.0000
5.0000
3.0000
0
1.8529
3.9118
1.0000
0
-6.7455
-0.0026
0
0
3.9142
1.0000
0
0
0.2193
0
0
0
1.0000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0

0
0
0
0
0
0
0

0
0
0
0
0
0
0

c1 =
Columns 1 through 7
1.0000
34.0000
11.3235
Columns 8 through 14
200.3194 -15.8777
22.4540
Columns 15 through 21
-1.1240 267.6909 -10.3127
No of sign changes::::8

0
0
0
0
0
0
0
11.8727

-53.5038

61.3345

4.2084

45.7841

67.9710

14.1972

-31.7438

-41.4337

3.7079

1.8736

1.0000

Interpretation of table
1-No. of sign changes is equal to number of poles in right half plane.
2-As the program also indicates the zero row. So observing the output c1 (1st column) poles on the jw axis
can be separated. They are equal to no. of sign changes after zero row.
3- If a no. of poles lie in R.H.P. and b poles lie on jw axis then for n degree polynomial, c=n-a-b
poles will be in L.H.P.
In Q#01, there are 10 sign changes with no zero row. So 10 poles in R.H.P. and 10 in L.H.P.
In Q#02, again there is no zero row. So, 8 poles lie in R.H.P. and 12 in L.H.P.

You might also like