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

  1. //-------------------------------------------------------------------------
  2. //
  3. // V = xvcost(X,Mp,GG,R,nu,nz,nc)
  4. //
  5. // Computes the control cost function
  6. //
  7. //   V = tr(UR)
  8. //
  9. // Which assigns the covariance X to the closed-loop system with
  10. // the feedback matrix GG
  11. //
  12. //  xc_dot = Ac * xc + F * z
  13. //       u =  G * xc + H * z
  14. //
  15. //  GG = [ H G  
  16. //         F Ac ]
  17. //
  18. // nu, nz, nc == dimensions of actuator, sensor 
  19. //               and controller state vectors
  20. //
  21. // L.D. Peterson
  22. // version 900305
  23. //
  24. // Note: current version does not check compatibility of dimensions
  25. //-------------------------------------------------------------------------
  26.  
  27. rfile xgpart
  28. rfile xhpart
  29.  
  30. xvcost = function(X,Mp,GG,R,nu,nz,nc)
  31. {
  32.    local(G,H,V)
  33.  
  34. // Get the G and H parts of GG
  35.  
  36.    G=xgpart(GG,nu,nz,nc);
  37.    H=xhpart(GG,nu,nz,nc);
  38.  
  39. // Calculate the cost and return
  40.  
  41.    V=trace([H*Mp,G]*X*[H*Mp,G]'*R);
  42.  
  43.    return V;
  44. };
  45.