%bike, from HW due  10/29/09
%CONSISTENT UNITS:  MKS

%GIVEN
P_p     = .5 * 746 ;     % one half horse power in watts
m       = 150/2.2 ;      % mass in kg
omega_f = 180*2*pi/60;   %  in rad/s
v_final = 20 *1600/3600  % in m/s

%MEASURED ON BIKE
%Chain wheel with 42 teeth, freewheel with 13 teeth
%Wheel with diameter of27 inches
G = (13/42) * (2/27) *(39.37); % units are m^-1


% Derived quantities (depends on calculations not shown)
M_0    = 4 * P_p/omega_f;  %Peak applied torque
A      = G*M_0/m  ;
B      = A *G/omega_f ;
lambda = B ;     
v_0    = omega_f/G; % also, v_0 = A/B
C      = omega_f/G;

%PLOT SOLUTION
t = linspace(0,10, 1000);
v = C*(1 - exp(-lambda*t));
x = C*(t + (1/lambda) * exp(-lambda*t)) ...
      - omega_f/(G*lambda); % constant from setting
                            % x = 0 at t = 0.

plot(t,v); title('vel vs time, m/s and seconds')

figure(2)
plot (t,x); title ('Position vs time, meters and seconds')

t_final = -log(1 - G*v_final/omega_f)/lambda
