Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.31 KB | None | 0 0
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %       Macro for running simulation
  3. %       of a SISO feedback system with
  4. %       the model servo1.mdl
  5. %
  6. %       The controller must be a tf assigned
  7. %       in workspace as Fsim
  8. %       The system must be a tf assigned
  9. %       in workspace as Gsim
  10. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  11.  
  12. % Fsim = F;
  13. % Gsim = G;
  14.  
  15. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  16. %       Parameters to edit
  17. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  18.  
  19. u_max=inf;              %maximum control signal
  20. sin_dist_freq=100*pi;   %frequency of sinusoid disturbance (rad/s)
  21. sin_dist_amp=1;         %amplitude of sinusoid disturbance
  22. white_noise_var=0;      %variance of white noise disturbance
  23. step_size=0;            %amplitude of step reference
  24. sim_time=10;            %simulation time (s)
  25.  
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. % s=tf('s');
  28. % G=1e4*(s+2)/(s+3)/(s+100)^2;
  29. % Go=minreal(1e4*((s+2)*(s-1))/((s+3)*(s+100)^2*(s+2)));
  30.  
  31.  
  32. sim('servo1',sim_time);
  33.  
  34.  
  35.  
  36.  
  37.  
  38. figure
  39. subplot(2,2,1)
  40. plot(t,r);
  41. title('reference');
  42. xlabel('time (s)')
  43.  
  44. subplot(2,2,2)
  45. plot(t,y);
  46. title('output');
  47. xlabel('time (s)')
  48.  
  49. subplot(2,2,3)
  50. plot(t,u);
  51. title('Control signal');
  52. xlabel('time (s)')
  53.  
  54. subplot(2,2,4)
  55. plot(t,w);
  56. title('Disturbance');
  57. xlabel('time (s)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement