Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- S = load('q3data.csv'); % loads data from file to the workspace
- f = S(:,1); % extract frequency
- xr = S(:,2); %reference signal
- x = S(:,3); % extract actual position
- t = S(:,4); % extract time delay
- for i=1:length(xr);
- freq(i) = 2*pi*f(i);
- period(i) = 1/f(i);
- g(i) = x(i)/xr(i);
- phase(i) = -360*t(i)/period(i);
- end
- zeta = 0.148;
- wn = 27.391;
- G = tf([wn*wn],[1 2*zeta*wn wn*wn]);
- w = linspace(1,2*pi*50,10000);
- [mag,shift]=bode(G,w);
- figure(1);
- subplot(2,1,1);
- loglog(freq,g,'Marker','o','LineStyle','none');
- hold on;
- %loglog(w,squeeze(mag));
- title('Bode Plot'); ylabel('Log Gain [mm/mm]'); xlabel('Log Frequency[rad/sec]'); grid on;
- subplot(2,1,2);
- semilogx(freq,phase,'Marker','o','LineStyle','none');
- hold on;
- %semilogx(w,squeeze(shift));
- ylabel('Phase [deg]'); xlabel('Log Frequency[rad/sec]'); grid on;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement