%
%   First control example: proportional control for cruise control.
%   B. Goodwine, January 14, 1999.  I called this file 'car.m'
%

b = 25;
m = 750;
lam = 0.5;
vd = 40;
kp = 100;
fe = b*vd;    % inital condition for engine 'force'

%   OutputFcn odeplot tells Matlab to plot the output
%   Outputsel [1] tells it to plot only the velocity (the
%   first component of y).
options = odeset('OutputFcn','odeplot','Outputsel',[1]);

%   In the following, t = time, and y is the state vector [v fe].
%   The [0 20] is the time range and [0 fe] are the initial conditions.
%   'proporational' tells this program to look at the file
%   'proportional.m' for the equations of motion.

[t y] = ode45('proportional', [0 20], [0 fe],options,b,m,lam,vd,kp);

