Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.86 KB | None | 0 0
  1. S = load('q3data.csv'); % loads data from file to the workspace
  2. f = S(:,1); % extract frequency
  3. xr = S(:,2); %reference signal
  4. x = S(:,3); % extract actual position
  5. t = S(:,4); % extract time delay
  6.  
  7. for i=1:length(xr);
  8.     freq(i) = 2*pi*f(i);
  9.     period(i) = 1/f(i);
  10.     g(i) = x(i)/xr(i);
  11.     phase(i) = -360*t(i)/period(i);
  12. end
  13.  
  14. zeta = 0.148;
  15. wn = 27.391;
  16. G = tf([wn*wn],[1 2*zeta*wn wn*wn]);
  17.  
  18. w = linspace(1,2*pi*50,10000);
  19.  
  20. [mag,shift]=bode(G,w);
  21.  
  22. figure(1);
  23. subplot(2,1,1);
  24.     loglog(freq,g,'Marker','o','LineStyle','none');
  25.     hold on;
  26.     %loglog(w,squeeze(mag));
  27. title('Bode Plot'); ylabel('Log Gain [mm/mm]'); xlabel('Log Frequency[rad/sec]'); grid on;
  28. subplot(2,1,2);
  29.     semilogx(freq,phase,'Marker','o','LineStyle','none');
  30.     hold on;
  31.     %semilogx(w,squeeze(shift));
  32. ylabel('Phase [deg]'); xlabel('Log Frequency[rad/sec]'); grid on;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement