r=1000
c=1e-6
p=1/(r*c)
p/(2*pi)

%vector=start:step:stop;
%t=t_start:dt;t_stop;
t=0:0.00001:0.1;
%f=f_start:df:f_stop;
f=1:1:10000;%Hz
om=2*pi*f;%rad/sec
s=j*om;
tf=p./(s+p);%V_in/V_out transfer function

figure(1)
subplot(211)
semilogx(f,abs(tf))
ylabel('Magnitude Ratio')

subplot(212)
phase=atan2(imag(tf),real(tf))*180/pi;
semilogx(f,phase)
ylabel('Phase (deg.)')
xlabel('Freq (Hz)')


%Time Plots
fdemo=[30,100,1000,5000];
sdemo=2.0*pi*j*fdemo;

tfdemo=p./(sdemo+p);
mdemo=abs(tfdemo);
phdemo=atan2(imag(tfdemo),real(tfdemo))*180/pi;

for i=1:length(fdemo);
    f_i=fdemo(i);
    T=1/f_i;
    m_i=mdemo(i);
    ph_i=phdemo(i)
    Vin=sin(2*pi*f_i*t);
    Vout=m_i*sin(2*pi*f_i*t+ph_i*pi/180);

    figure(1+i)
    plot(t,Vin, t, Vout)
    xlim([0,3*T])
end

V_in=sin(2*pi*fdemo(3)*t);
V_bogus=mdemo(3)*sin(2*pi*fdemo(3)*t);
T=1/fdemo(3);

figure(6)
plot(t,V_in, t, V_bogus)
xlim([0,3*T])