-
Notifications
You must be signed in to change notification settings - Fork 0
/
DragFromTelemetry.m
31 lines (23 loc) · 1023 Bytes
/
DragFromTelemetry.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%% Telemetry Analysis
% Jacob Petrie
function DragFromTelemetry(telemetryFilename, outputFilename, airDensity, mass)
DATA = readtable(telemetryFilename);
A = 1.262; % frontal area, m^2, Source: Ben Colby
gravity = 9.81; % m/s
weight = mass * gravity;
%% Compute acceleration at every instant
times = DATA.Var1; % no column header for the timestamps so it is 'var1' by default
speeds = DATA.speed;
% Unit conversion
mphToMetersPerSecond = 0.44704;
millisecondsToSecond = 1/1000;
times = times .* millisecondsToSecond;
speeds = speeds .* mphToMetersPerSecond;
% Calculate acceleration
accel = diff(speeds) ./ diff(times); % TODO: convert from forward to central difference
force = mass * accel;
% Subtract off rolling resistance
dragForce = force - rollingResistance(speeds(1:(end-1)), weight);
dragCoeff = dragForce ./ ( 0.5 * airDensity * A * (speeds(1:(end-1)).^2) );
% Calculate Drag coefficient at each speed
end