Pole Zero Plot from System function H(Z) Expressed as Rational Function

Posted by fasxxzczc on Wednesday 21 March 2012

Pole Zero Plot from  System function H(Z) Expressed as Rational Function


Problem Statement :Draw a pole zero plot from a given system function H(Z) expressed as rational function. (Display pole zero table and pole zero plot) .



1:  #include<iostream.h>  
2:  #include<conio.h>  
3:  #include<stdio.h>  
4:  void main(void)  
5:  {  
6:   int pol[5]={0},zer[5]={0},num1,num2,a[6],b[6],i;  
7:   clrscr();  
8:   cout<<"\n\tInput number of poles for x(n)(MAX 5)::";  
9:   cin>>num1;  
10:   cout<<"\n\tInput Values::\n";  
11:   for(i=1;i<=num1;i++)  
12:   {  
13:   cout<<"\n\tp["<<i<<"]::";  
14:   cin>>pol[i];  
15:   }  
16:   cout<<"\n\tInput number of zeros for x(n)(MAX 5)::";  
17:   cin>>num2;  
18:   cout<<"\n\tInput Values::\n";  
19:   for(i=1;i<=num2;i++)  
20:   {  
21:   cout<<"\n\tz["<<i<<"]::";  
22:   cin>>zer[i];  
23:   }  
24:   a[0]=b[0]=1;  
25:   a[1]=-(pol[1]+pol[2]+pol[3]+pol[4]+pol[5]);  
26:   a[2]=pol[1]*(pol[2]+pol[3]+pol[4]+pol[5])+pol[2]*(pol[3]+pol[4]+pol[5])  
27:     +pol[3]*(pol[4]+pol[5])+pol[4]*pol[5];  
28:   a[3]=-(pol[1]*pol[2]*(pol[3]+pol[4]+pol[5])+pol[2]*pol[3]*(pol[4]+pol[5])  
29:     +pol[4]*pol[5]*(pol[1]+pol[2]+pol[3])+pol[1]*pol[3]*(pol[4]+pol[5]));  
30:   a[4]=pol[1]*pol[2]*pol[3]*(pol[4]+pol[5])+pol[3]*pol[4]*pol[5]*(pol[1]+  
31:     pol[2])+pol[1]*pol[2]*pol[4]*pol[5];  
32:   a[5]=-(pol[1]*pol[2]*pol[3]*pol[4]*pol[5]);  
33:   b[1]=-(zer[1]+zer[2]+zer[3]+zer[4]+zer[5]);  
34:   b[2]=zer[1]*(zer[2]+zer[3]+zer[4]+zer[5])+zer[2]*(zer[3]+zer[4]+zer[5])  
35:     +zer[3]*(zer[4]+zer[5])+zer[4]*zer[5];  
36:   b[3]=-(zer[1]*zer[2]*(zer[3]+zer[4]+zer[5])+zer[2]*zer[3]*(zer[4]+zer[5])  
37:     +zer[4]*zer[5]*(zer[1]+zer[2]+zer[3])+zer[1]*zer[3]*(zer[4]+zer[5]));  
38:   b[4]=zer[1]*zer[2]*zer[3]*(zer[4]+zer[5])+zer[3]*zer[4]*zer[5]*(zer[1]+  
39:     zer[2])+zer[1]*zer[2]*zer[4]*zer[5];  
40:   b[5]=-(zer[1]*zer[2]*zer[3]*zer[4]*zer[5]);  
41:   cout<<"\n\nCoefficient for x(n)::";  
42:   for(i=0;i<=num1;i++)  
43:       cout<<b[i]<<",";  
44:   cout<<"\b ";  
45:   cout<<"\n\nCoefficient for y(n)::";  
46:   for(i=0;i<=num2;i++)  
47:       cout<<a[i]<<",";  
48:   cout<<"\b ";  
49:   getch();  
50:  }  

{ 0 comments... read them below or add one }

Post a Comment