home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts / control / susball.m < prev    next >
Encoding:
Text File  |  1999-12-15  |  2.7 KB  |  102 lines

  1. ## Copyright (C) 1996 Auburn University.  All Rights Reserved.
  2. ##
  3. ## This file is part of Octave. 
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it 
  6. ## under the terms of the GNU General Public License as published by the 
  7. ## Free Software Foundation; either version 2, or (at your option) any 
  8. ## later version. 
  9. ## 
  10. ## Octave is distributed in the hope that it will be useful, but WITHOUT 
  11. ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  12. ## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
  13. ## for more details.
  14. ## 
  15. ## You should have received a copy of the GNU General Public License 
  16. ## along with Octave; see the file COPYING.  If not, write to the Free 
  17. ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. 
  18.  
  19. ## -*- texinfo -*-
  20. ## @deftypefn {Function File } { outputs =} susball ( inputs ) 
  21. ## @format
  22. ## @end format
  23. ## @end deftypefn
  24.  
  25. cmd = "ballsys = margetsys(""disc"")";
  26. eval(cmd);
  27.  
  28. disp("Design LQG controller");
  29. cmd = "sysout(ballsys)";
  30. run_cmd
  31. disp("add noise inputs to system...")
  32.  
  33. disp("discrete system:")
  34. [nn,nz,mm,pp] = sysdimensions(ballsys);
  35. cmd = "ballsys = sysappend(ballsys,nz);";
  36. run_cmd 
  37.  
  38. cmd = "sysout(ballsys)";
  39. run_cmd
  40.  
  41. disp("Notice the two additional inputs, u_2, and u_3.  These are the ");
  42. disp("""entry points"" for the gaussian noise disturbance.");
  43. disp(" ");
  44. disp("We'll design the controller to use only position feedback:")
  45.  
  46. cmd = "ballsys=sysprune(ballsys,1,[]);";
  47. run_cmd
  48. cmd = "sysout(ballsys)";
  49. run_cmd
  50.  
  51. disp("Now design an LQG controller: Sigw: input noise")
  52. Sigw = eye(2)
  53. disp("Now design an LQG controller: Sigv: measurement noise")
  54. Sigv = eye(pp);
  55.  
  56. disp("State and input penalties:")
  57. Q = eye(2)
  58. R = 1
  59. disp("Controlled input is input 1");
  60.  
  61. cmd="Ksys = lqg(ballsys,Sigw,Sigv,Q,R,1);";
  62. run_cmd
  63.  
  64. disp("sysout(Ksys);");
  65. sysout(Ksys);
  66.  
  67. disp("\nGet rid of the disturbance inputs");
  68. cmd = "ballsys = sysprune(ballsys,1,1);"
  69. run_cmd;
  70. sysout(ballsys);
  71. sysout(ballsys,"zp");
  72.  
  73. disp("\nGrouping the plant and the controller");
  74. cmd = "closed_loop = sysgroup(ballsys,Ksys);"
  75. run_cmd;
  76. sysout(closed_loop);
  77.  
  78. disp("\nduplicating the plant input");
  79. cmd = "closed_loop = sysdup(closed_loop,[],1);"
  80. run_cmd;
  81. sysout(closed_loop);
  82.  
  83. ## disp("\nscaling the duplicated input by -1");
  84. ## cmd = "closed_loop = sysscale(closed_loop,[],diag([1,1,1]));"
  85. ## run_cmd;
  86. ## sysout(closed_loop);
  87.  
  88. disp("\nconnecting plant output to controller input and controller output");
  89. disp("to the duplicated plant input");
  90. cmd = "closed_loop = sysconnect(closed_loop,[1 2],[2 3]);"
  91. run_cmd;
  92. sysout(closed_loop);
  93.  
  94. disp("\nkeeping only the original plant input and plant output");
  95. cmd = "closed_loop = sysprune(closed_loop,1,1);"
  96. run_cmd;
  97. sysout(closed_loop);
  98.  
  99. sysout(closed_loop,"zp");
  100.  
  101.  
  102.