home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Mathematics / Notebooks / COSY_PAK / COSYPAK / chap1.m next >
Text File  |  1992-06-07  |  3KB  |  93 lines

  1.  
  2. (* 
  3. **********************************************************
  4.  
  5.             COSY_PAK package chap1.m        
  6.  
  7. **********************************************************
  8. *)
  9.  
  10. If [ TrueQ[ $VersionNumber >= 2.0 ],
  11.      Off[ General::spell ];
  12.      Off[ General::spell1 ] ]
  13.      
  14. (*  B E G I N     P A C K A G E  *)
  15.      
  16. BeginPackage["COSYPAK`chap1`","Algebra`ReIm`",
  17.         "SignalProcessing`Support`SigProc`", 
  18.         "SignalProcessing`Analog`LaPlace`",
  19.         "SignalProcessing`Analog`InvLaPlace`",
  20.         "SignalProcessing`Analog`LSolve`"];
  21.  
  22. ChekAnal::usage = 
  23. "ChekAnal[Transf, s, r, w,showder]:  Checks the analyticity of the transfer function Transf(s) at the point s=r+jw using Cauchy-Reimann conditions.  If `showder=1' (optional) then the derivatives in the computation are shown. ";
  24.  
  25. PoleZeros::usage = 
  26. "PoleZeros[Transf, s]: Computes finite  poles and zeros of the transfer function Transf . Returns {list of poles, list of zeros}.
  27. ";
  28.  
  29. Begin["`Private`"];
  30.  
  31. (* Function to check the analyticity of the transfer function *)
  32.  
  33. ChekAnal[Transf_,s_, r_,w_]:= ChekAnal[Transf,s, r,w,n] ;
  34.  
  35. ChekAnal[Transf_,s_, r_,w_,showdrv_]:=
  36. Block[{g,greal,gimag,sol,dGrealr,dGrealw,dGimagr,dGimagw,poles},
  37.     r/:Im[r]=0; w/:Im[w]=0; 
  38.     g = ExpandAll[Transf/.s->(r + w I)];
  39.     greal = Simplify[Re[g]]; gimag = Simplify[Im[g]];
  40.     Print[" G(r + w I) = ", greal + I gimag ];
  41.     
  42.     dGrealr = D[greal,r];    (* derive real part of G(r + w I) *) 
  43.     dGrealw = D[greal,w];    
  44.     
  45.     dGimagr = D[gimag,r];    (* derive imaginary part of G(r + w I) *)
  46.     dGimagw = D[gimag,w];
  47.     
  48.     (* Show the derivatives *)
  49.     If[ showdrv==1,
  50.        Print["The derivatives:"]; 
  51.        Print["d Re[G(r + w I)] /dr = ",Together[dGrealr] ];    
  52.        Print["d Re[G(r + w I)] /dw = ",Together[dGrealw] ];
  53.        Print["d Im[G(r + w I)] /dr = ",Together[dGimagr] ];
  54.        Print["d Im[G(r + w I)] /dw = ",Together[dGimagw] ] 
  55.        ];    
  56.     
  57.     (* dGx/dsigma - dGy/domega *)
  58.     If[ (Simplify[dGrealr-dGimagw] ==0) &&
  59.         (Simplify[dGrealw+dGimagr] ==0),
  60.  
  61.       poles = Solve[ Denominator[Simplify[Transf]] ==0, s];  
  62.       Print["    "];  
  63.       Print["The Transfer function G(s)= ", Transf," IS an analytical",
  64.          " function except at the singulality points: ", s/.poles],
  65.       Print["The Transfer function G(s)= ", Transf," IS NOT an analytical",
  66.          " function."]
  67.        ];
  68.       ];
  69.       
  70. (* Function list the zeros and poles of the transfer function *)
  71. PoleZeros[Transf_,s_]:=
  72. Block[{gg,gden,gnum},
  73.     gg = Simplify[Transf];
  74.     gden = Denominator[gg] ;
  75.     gnum = Numerator[gg];
  76.     poles = N[Solve[gden ==0, s]]; 
  77.     zeros = N[Solve[gnum ==0, s]];
  78.     Print["The transfer function G(s)= ", Transf];     
  79.     Print["    " ];
  80.     Print["The Poles of G(s) is:",s/.poles];
  81.     Print["    " ];
  82.     Print["The Zeros of G(s) is:",s/.zeros];
  83.     Return[{s/.poles,s/.zeros}]
  84.     ];    
  85. End[]
  86. EndPackage[];
  87.  
  88. (*  E N D     P A C K A G E  *)
  89.  
  90. If [ TrueQ[ $VersionNumber >= 2.0 ],
  91.      On[ General::spell ];
  92.      On[ General::spell1 ] ]
  93.