% BodePlot_DesignProj_ex.m
% Example for making Bode Plots for final presentation
% Note:  you must also include the phase plot.

% Experimental data taken in the lab
f_data = [1e-2 1e-1 1 10 100 1000 10000];
mag_data = [30 10 9 4 -2 -3 -3];

% You will also need phase data
%  phase_data = [ ];

% values from the transfer function for your circuit
f_trans = logspace(-2, 4);
omega = 2*pi*f_trans;

% you may want to write out expressions for your transfer function
% in terms of R, L and C values, so that as/if you change these values
% Matlab will automatically update your expressions
%  R = 
%  C =
%  L =

% I am putting in hypethetical numerator and demoninator expressions here
% for the example - probably *not* what you want to do
% recall that 's' = j*omega
Vtrans = 80*(5*j*omega + 1)./((j*j*omega.*omega) + 35*j*omega + 0.125);
Vtrans_mag = abs(Vtrans);

% For the phase plot you will need something like...
% Vtrans_phase = angle(Vtrans);

figure(1)
clf
subplot(211)
semilogx(f_data, mag_data,'b+')
hold on
semilogx(f_trans,Vtrans_mag,'r-')
ylabel('Magnitude')

% phase plot
subplot(212)
% semilogx(f_data,phase_data,'b+')
% hold on
% semilogx(f_trans,Vtrans_phase,'r-')
xlabel('Frequency (Hz)')
ylabel('Phase (Radians)')

suptitle('Vo/Vs')

