aprsc7

Transfer function to state space

Nov 27th, 2020 (edited)
1,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.69 KB | None | 0 0
  1. % Transfer function to steady state
  2. % Chapter4 Example 1
  3. clear
  4. clc
  5. %% Input:
  6.  
  7. numg = [24]; % Define numerator of G(s)
  8. deng = [1 9 26 24]; % Define denominator of G(s)
  9.  
  10. %% Process
  11. G = tf(numg,deng) % Generate transfer function G(s)
  12. type = input("1-Phase Variable; 2-Controller Cononical; 3-Observer Cononical?\n");
  13.  
  14. % Controller Cononical
  15. [Ac Bc Cc Dc] = tf2ss(numg,deng);
  16.  
  17. % Phase Variable
  18. P = flip(eye(order(G)));
  19. A = inv(P)*Ac*P;
  20. B = inv(P)*Bc;
  21. C = Cc*P;
  22. D = Dc;
  23.  
  24. % Observer Cononical
  25. Ao = Ac';
  26. Bo = Cc';
  27. Co = Bc';
  28. Do = Dc;
  29.  
  30. if(type == 3)
  31.     Ao
  32.     Bo
  33.     Co
  34.     Do
  35.    
  36. elseif(type == 2)
  37.     Ac
  38.     Bc
  39.     Cc
  40.     Dc
  41. else
  42.     A
  43.     B
  44.     C
  45.     D
  46. end
  47.        
  48.  
Add Comment
Please, Sign In to add comment