home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / r / rlab / CTB / appendtest < prev    next >
Encoding:
Text File  |  1995-11-15  |  1.4 KB  |  67 lines

  1. //-----------------------------------------------------------------------------
  2. // ******************
  3. // * APPEND Testing *
  4. // ******************
  5. //
  6. // Version JBL 950106
  7. //
  8.  
  9. rfile append
  10.  
  11. // Ref: MATLAB Control Toolbox Manual
  12. A1=[0,1;2,3];
  13. B1=[0;1];
  14. C1=[1,0];
  15. D1=[1];
  16.  
  17. A2=[0,1,0;-1,-3,-0.5;0,0,4];
  18. B2=[0;1;1];
  19. C2=[1,1,1];
  20. D2=[0];
  21.  
  22. Dum=append(A1,B1,C1,D1,A2,B2,C2,D2);
  23.  
  24. Aex=[0,1,0,0,0;2,3,0,0,0;0,0,0,1,0;0,0,-1,-3,-0.5;
  25.      0,0,0,0,4];
  26. Bex=[0,0;1,0;0,0;0,1;0,1];
  27. Cex=[1,0,0,0,0;0,0,1,1,1];
  28. Dex=[1,0;0,0];
  29.  
  30. // Check results
  31. // Appended A matrix
  32. Enorm=norm(Dum.aa-Aex);
  33. printf ("APPEND: A matrix check (this matrix ought to be ZERO)\n");
  34. Dum.aa-Aex
  35. printf("%s","Norm of difference = ");
  36. sprintf(sdum,"%12.5e",Enorm);
  37. s="   "+sdum;
  38. printf("%s\n",s);
  39.  
  40. // Appended B matrix
  41. Enorm=norm(Dum.ba-Bex);
  42. printf ("APPEND: B matrix check (this matrix ought to be ZERO)\n");
  43. Dum.ba-Bex
  44. printf("%s","Norm of difference = ");
  45. sprintf(sdum,"%12.5e",Enorm);
  46. s="   "+sdum;
  47. printf("%s\n",s);
  48.  
  49. // Appended C matrix
  50. Enorm=norm(Dum.ca-Cex);
  51. printf ("APPEND: C matrix check (this matrix ought to be ZERO)\n");
  52. Dum.ca-Cex
  53. printf("%s","Norm of difference = ");
  54. sprintf(sdum,"%12.5e",Enorm);
  55. s="   "+sdum;
  56. printf("%s\n",s);
  57.  
  58. // Appended D matrix
  59. Enorm=norm(Dum.da-Dex);
  60. printf ("APPEND: D matrix check (this matrix ought to be ZERO)\n");
  61. Dum.da-Dex
  62. printf("%s","Norm of difference = ");
  63. sprintf(sdum,"%12.5e",Enorm);
  64. s="   "+sdum;
  65. printf("%s\n",s);
  66.  
  67.