%% Open Loop Cruise Control Example
%
% BJ Furman
% 
% 29AUG2014
%% Level Ground - No disturbance
clear all;
close all;
m=1000; % kg
b=50; % N-s/m
g=9.81 % m/s^2
Theta0=30*pi/180; % radians
Ke=500/Theta0; % N/rad
t=0:0.5:100;
v=(Ke*Theta0/b)*(1-exp((-b/m)*t));
plot(t,v)
xlabel('Time, s')
ylabel('Velocity, m/s')
title('Velocity vs. Time for Open Loop Cruise Control')
grid
hold on
%% Add a disturbance of a grade
% 
grade=3 % 3% grade (about 1.7 deg)
angle=atan(grade/100);
Fd=m*g*sin(angle)
vd=((Ke*Theta0-Fd)/b)*(1-exp((-b/m)*t));
plot(t,vd,'r')
legend('Level ground - no disturbance',strcat(num2str(grade),' % grade'),'Location','Best')
