Contents
clc;clear;close; % This clears the command window, clears to workspace and % closes any open windows, respectively. I'm in the habit % of placing this at the top of all my highest level scripts % as it helps reduce possible issues. FD = (4:1:10); % The design set of final drive ratios that are to be investigated max_time = 60; % [s] sim_time_step = 0.1; % [s], step time of the simulation max_ind = round(max_time/sim_time_step); v_end = 66.8224; % [m/s], final speed to stop the simulation (60 mph) % Preallocating the zero-to-sixty times that are to be used. times = NaN(size(FD)); Outputs = NaN(max_ind+1,6,length(FD)); % this is a 3d array, where the third index is the dimension of FD
Call the simulation function for all of the FDs of interest
for i = 1:length(FD) [times(i),Outputs(:,:,i)] = test_code(FD(i),max_ind,sim_time_step,v_end); end
Plotting
% Plot of the 0-60 times as a function of FD figure(1); plot(FD,times);xlabel('Final Drive Ratio');ylabel('0-60 Times [s]');title('Acceleration Times vs. FD'); t = Outputs(:,1,1); v = Outputs(:,2,1); eng_speed = Outputs(:,3,1); figure(2); plot(t,v);xlabel('Time, [s]');ylabel('Vehicle Speed, [m/s]');title('Vehicle Speed vs. Time, FD=4'); figure(3); plot(t,eng_speed);xlabel('Time, [s]');ylabel('Engine Speed, [RPM]');title('Engine Speed vs. Time, FD=4');