Académique Documents
Professionnel Documents
Culture Documents
PROJECT
GROUP H
After importing the data file given, the data read had to be separated so that
it could be used for further analysis. The default function of MATLAB, numel
was used to return the number of elements in the data. The longitudinal G-
force, latitudinal G-force and ground speed, of the race car, were given at
time intervals of 0.02s. The units of ground speed had to be changed from
km/hr to m/s by multiplying the ground speed with 5/18. As 1 g-force is 9.81
m/s2, we have to multiply the g-force data in each time interval with 9.81.
S=
1.5. Determining the Position
Each measurement of velocity (or ground speed) and lateral acceleration
(or g-force) at different times is separated by a finite t. In our case, t is
0.02s.
To track the forward position of our car, we can use the velocity of the car:
s(n+1) - s(n) =
v(n).t,
s(n+1) = s(n) +
The angle between the final direction and initial direction can be
expressed as follows:
(n+1) - (n) =
(a(n).t)/v(n),
(n+1) = (n) +
Using the formulas stated we can calculate the displacement in x
direction and displacement in y direction. The basic formula is:
x(n+1) = x(n) +
v(n).t.cos(n+1)
y(n+1) = y(n) +
Plotting graphs
To plot the graphs of longitudinal G-force and latitudinal G-force vs time,
acceleration vs time, velocity vs time, ground speed vs time, displacement vs
time and distance vs time in the same window, the function subplot was
used; having three rows and two columns with six different positions.
For each graph, the x and y labels, the title, axis properties, position was
entered separately. Since longitudinal G-force and latitudinal G-force are on
the same graph, so the function legend is used to identify each data set.
Flowcharts
Main Process Flow
Detailed fl owchart
Output Plots
Plot of the Race Track
Appendix
Documentation
%--------------------------------------------------------------------------
% Input: Text File containing data:
% 1. Time (T)
% 2. Ground Speed (G_Speed)
% 3. Longitudinal G-Force (GF_Lng)
% 4. Lateral G-Force (GF_Lat)
%
% Outputs: 1. Position coordinates for the race car over one lap
% 2. Graphs:
% 2.a.Longitudinal and lateral G?forces w.r.t time
% 2.b.Acceleration vs Time
% 2.c.Velocity vs Time
% 2.d.Ground Speed vs Time
% 2.e.Displacement vs Time
% 2.f.Distance vs Time
%
%
% Author(s): Sean Kurian George
% Umm Kulsoom Emad Ul Mukhtar
% Hamdah Abdul Ghafoor
%
% Date: December 07, 2016
%-------------------------------------------------------------------------
Calculating acceleration
%Note that the '.' operator does elementwise operation.
A = sqrt((GF_Lng .^ 2) + (GF_Lat .^ 2));%Acceleartion in ms^-2
Calculating distance
%DISTANCE = SPEED x TIME
dt = 0.02; %Since each time interval is 0.02s
D(1) = G_Speed(1) * dt; % We calculate the first element of D
for i=2:numel(G_Speed)
dx = G_Speed(i) * dt;%Distance = Speed x Time (distance in 0.02s)
D(i) = D(i-1) + dx;%Adding up the distance covered in time interval
end
clear i dx dt% Clearing unwanted variables from workspace
Calculating velocity
%VELOCITY = ACCELERATION x TIME
%V = U + A*T ( V=final velocity, U=initial velocity, A=Acceleration)
dt = 0.02; %Since each time interval is 0.02s
V(1) = GF_Lng(1) * dt; % We calculate the first element of V
for i=2:numel(GF_Lng)
V(i) = V(i-1) + GF_Lng(i) * dt;%V = U + A*T
end
clear i dt % Clearing unwanted variables from workspace
Calculating Position
dt = 0.02; %time interval of 0.02s
Alpha(1) = 0; % Angle
x(1) = 0; % x position
y(1) = 0; % y position
Ddt = G_Speed * dt;% Distance covered in 0.02s
n = numel(T);
for i = 2:n
% Formula to calculate the angles
Alpha(i) = Alpha(i-1) + (GF_Lat(i-1) * dt) / G_Speed(i-1);
x(i) = (x(i-1) + Ddt(i) * cos(Alpha(i))); %x displacement
y(i) = (y(i-1) + Ddt(i) * sin(Alpha(i))); %y displacement
end
clear i n dt %clearing unwanted variables from workspace
Calculating displacement
S = sqrt((x.^2 + y.^2));%Formula for displacement
Plotting racetrack
figure
%multiplying x and y with -1 closely resembles
%Thruxton, England racetrack from dataabase.
plot(-1.*x,-1.*y,'*')
title('Race Track (Thruxton, England)')
importfile function.
function DATA = importfile(filename, startRow, endRow)
Initialize variables.
delimiter = ':';
if nargin<=2
startRow = 1;
endRow = inf;
end
formatSpec = '%*s%f%[^\n\r]';
end