aprsc7

Chapter 4

Dec 22nd, 2020 (edited)
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.69 KB | None | 0 0
  1. % Chapter 4 example 3
  2. clear
  3. clc
  4. sympref('FloatingPointOutput',true)
  5. syms s k1 k2 k3 k4 ke;
  6.  
  7. %% Input:
  8.  
  9. numg = [20 100];
  10. deng = poly([0 1 4]);
  11. Ts = 0.74;  
  12. Os = 9.5;    
  13. zeros = s+5;
  14.  
  15. %% Process
  16.  
  17. G = tf(numg,deng)   % Generate transfer function G(s)
  18. [Ac Bc Cc Dc] = tf2ss(numg,deng);
  19. P = flip(eye(order(G)));
  20. A = inv(P)*Ac*P
  21. B = inv(P)*Bc
  22. C = Cc*P
  23. D = Dc
  24.  
  25. zeta = (-log(Os/100))/(sqrt(pi^2+log(Os/100)^2));
  26. Wn = 4/(zeta*Ts);
  27.  
  28. %% state-feedback control
  29.  
  30. pole1 = s^2 + 2*zeta*Wn*s + Wn^2;
  31. pole2 = zeros
  32.  
  33. Anew = A-(B*[k1 k2 k3])
  34.  
  35. Ds = expand(pole1*pole2)
  36. Ts = det(s*eye(3)-Anew)
  37.  
  38. % Solve
  39. Dsm = coeffs(Ds,s);
  40. Tsm = coeffs(Ts,s);
  41. k = vpa(struct2cell((solve(Dsm==Tsm))))
  42.  
Add Comment
Please, Sign In to add comment