home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / languages / rlab1_23a / CTB / aretest < prev    next >
Text File  |  1995-11-14  |  997b  |  57 lines

  1.  
  2. // This routine tests the continuous lqr solution methods using examples
  3. // from Laub's paper.
  4.  
  5. rfile banner
  6. rfile lqr
  7. rfile are2
  8.  
  9. banner("Continuous lqr QA");
  10. // =============================================
  11. //                     Test 1:
  12. // =============================================
  13.  
  14. printf("%s"," \n");
  15. banner("Test1");
  16.  
  17. A=[0,1;0,0];
  18. B=[0;1];
  19. R=[1];
  20. Q=[1,0;0,2];
  21.  
  22. P=[2,1;1,2];
  23.  
  24. P2=are2(A,B,Q,R);
  25.  
  26. // Check norm of the error
  27. Pnorm=norm(P-P2);
  28. printf("%s","Norm of solution error = ");
  29. sprintf(sdum,"%12.5e",Pnorm);
  30. s="   "+sdum;
  31. printf("%s\n",s);
  32.  
  33. // =============================================
  34. //                     Test 2:
  35. // =============================================
  36.  
  37. printf("%s"," \n");
  38. banner("Test2");
  39.  
  40. A=[4,3;-(9/2),-(7/2)];
  41. B=[1;-1];
  42. R=[1];
  43. Q=[9,6;6,4];
  44.  
  45. // RLaB lqr routine solution
  46. X=lqr(A,B,Q,R);
  47. P=X.p
  48.  
  49. P2=are2(A,B,Q,R);
  50.  
  51. // Check norm of the error
  52. Pnorm=norm(P-P2);
  53. printf("%s","Norm of solution error = ");
  54. sprintf(sdum,"%12.5e",Pnorm);
  55. s="   "+sdum;
  56. printf("%s\n",s);
  57.