

% mtbode.m

%  This Matlab script generates Bode diagram based on the
%  frequency, magnitude and phase data you obtain in
%  Servo motor experiment.
%
%  Directions:
%  - Your input to this program should be in the form of
%       [.1  .3  .4 ]
%  - Do not forget to type the square brackets  
%  - The vector length of frequency, magnitude and phase
%    should be consistent.
%  - You may use "axis([xL xU yL yU])" to rescale the axis
%	  where xL is the lower limit on the x axis
%          xH is the higher limit on the x axis
%          yL is the lower limit on the y axis
%          yH is the higher limit on the y axis

%-----------------------------------------------------------
%
%
echo off


f= [ .5 1 2 3 4 5 10 15 20 25 30]
mag=[1.375 1.75 1.5 1.625 1.5 1.375 1 .875 .688 .5 .375]
phase=-1*[11.25 19.8 25.2 29.7 36 40.5 54 67.5 72 54 64.8]

subplot(211)
semilogx(f,20*log10(mag))
xlabel('Frequency (Hz)')
ylabel('Magnitude (dB)')
grid

subplot(212)
semilogx(f,phase)
xlabel('Frequency (Hz)')
ylabel('Phase (deg)')
grid