Advertisement
Guest User

Untitled

a guest
Sep 12th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.70 KB | None | 0 0
  1. %% Parameters
  2. m = 1000; % Mass kg
  3. b = 50; % Friction
  4.  
  5. A = -b/m;
  6. B = 1/m;
  7. C = 1;
  8. D = 0; % Does not need. ss function will auto generate D
  9. delay = 0;
  10.  
  11. %% Model
  12. cruise_ss = ss(delay,A,B,C,D);
  13.  
  14. %% Discrete model
  15. h = 0.2; % sample time
  16. cruise_ss_d = c2d(cruise_ss, h);
  17.  
  18. %% Reference model
  19. K = 1; % Highest point
  20. T = 1; % Time constant
  21. G = tf(K, [T 1])
  22. Gd = c2d(G, h);
  23. step(Gd);
  24.  
  25. %% Find the pole
  26. p = pole(Gd)
  27.  
  28. %% Pole placement
  29. L = acker(cruise_ss_d, [p])
  30.  
  31. % Compute the closed loop model
  32. cruise_ss_d_cl = reg(cruise_ss_d, L);
  33.  
  34. %% Add reference gain for better tracking
  35. cruise_ss_d_cl_kr = referencegain(cruise_ss_d_cl);
  36.  
  37. %% Simulate now
  38. figure
  39. y = step(cruise_ss_d_cl_kr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement