%% Open Loop Cruise Control Example With Multiple Plots
%
% BJ Furman
% 
% 29AUG2014
%% Build data
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
grade=[-1 0 1 2 3]; % -1, 0, 1,2, 3% grades
angle=atan(grade/100);
Fd=m*g*sin(angle);
t=0:0.5:100;
v=((Ke*Theta0-Fd)/b)'*(1-exp((-b/m)*t)); % performs 'Outer Product' to generate multiple curves
plot(t,v)
xlabel('Time, s')
ylabel('Velocity, m/s')
title('Velocity vs. Time for Open Loop Cruise Control')
grid
legend(strcat(num2str(grade'),' % grade'),'Location','Best')
