Advertisement
aprsc7

Control system observer

Nov 17th, 2020 (edited)
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.14 KB | None | 0 0
  1. % Control observer
  2. % Input from example 2-5
  3. sympref('FloatingPointOutput',true)
  4. clear
  5. clc
  6. %% Input:
  7.  
  8. A = [-24 1 0; -191 0 1; -504 0 0]           % A matrix
  9. B = [0; 1; 6]                               % B matrix
  10. C = [1 0 0]                                 % C matrix
  11. Ts = 2;                                     % Time settling
  12. Tp = 0;                                     % Time peak
  13. Os = 0.2;                                   % Overshoot (100%=1.0)
  14. zeta = 0;                                   % Zeta
  15. Wn = 0;                                     % Natural frequency
  16. speed = 10;                                 % speed to be faster
  17.  
  18. %% Process:
  19.  
  20. syms s L1 L2 L3 ke;
  21. if(zeta==0)
  22.     zeta = -(log(Os)/log(exp(1)))/sqrt(pi^2+(log(Os)/log(exp(1)))^2);
  23.     if(Tp==0) Wn = 4/(zeta*Ts);
  24.     else Wn = pi/(Tp*sqrt(1-zeta^2)); end
  25. end
  26.  
  27. pole1 = s+zeta*Wn*speed + (Wn*sqrt(1-zeta^2)*1i)*speed;
  28. pole2 = s+zeta*Wn*speed - (Wn*sqrt(1-zeta^2)*1i)*speed;
  29. pole3 = s+zeta*Wn*speed*10;
  30. Anew = A-[L1; L2; L3]*C
  31.  
  32. Ds = expand(pole1*pole2*pole3)
  33. Ts = det(s*eye(3)-Anew)
  34.  
  35. % Solve
  36. Dsm = coeffs(Ds,s);
  37. Tsm = coeffs(Ts,s);
  38. L = vpa(struct2cell((solve(Dsm==Tsm))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement