aprsc7

Feedback control with integral

Nov 9th, 2020 (edited)
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.86 KB | None | 0 0
  1. % Feedback control with integral
  2. % Input from example 2-4
  3. sympref('FloatingPointOutput',true)
  4. clear
  5. clc
  6. %% Input:
  7.  
  8. A = [0 1; -7 -9]                % A matrix
  9. B = [0; 1]                      % B matrix
  10. C = [4 1]                       % C matrix
  11. Ts = 0;                         % Time settling
  12. Tp = 2;                         % Time peak
  13. Os = 0.1;                       % Overshoot (100%=1.0)
  14. zero = -4;                      % Open loop zero
  15.  
  16. %% Process:
  17.  
  18. syms s k1 k2 k3 ke;
  19. zeta = -(log(Os)/log(exp(1)))/sqrt(pi^2+(log(Os)/log(exp(1)))^2);
  20. if(Tp==0) Wn = 4/(zeta*Ts);
  21. else Wn =  pi/(Tp*sqrt(1-zeta^2));
  22. end
  23.  
  24. a11 = A-(B*[k1 k2]);
  25. a12 = B*ke;
  26. a21 = -C;
  27. Anew = [a11 a12; a21 0]
  28.  
  29. Ds = expand((s^2 + 2*zeta*Wn*s + Wn^2)*(s-zero))
  30. Ts = det(s*eye(3)-Anew)
  31.  
  32. % Solve
  33. Dsm = coeffs(Ds,s);
  34. Tsm = coeffs(Ts,s);
  35. k = vpa(struct2cell((solve(Dsm==Tsm))))
  36.  
  37.  
  38.    
Add Comment
Please, Sign In to add comment