-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdockingSimulation.m
More file actions
46 lines (35 loc) · 1.55 KB
/
dockingSimulation.m
File metadata and controls
46 lines (35 loc) · 1.55 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%{
Author: Shane Kramer
Course: SPCE 5605 Modeling and Simulation
Date: 04.30.15
---------------------------------------------------
This function performs a two vehicle docking simulation,
where the # of docking/acceleration steps, and total
docking time are calulated from:
* closingVelocity - The initial closing velocity
* k - Constant or proportionality for acceleration control.
* adjustmentTime - The amount of time it takes to make an
adjustment
* revisitTime -Time it takes astonaut to check velocity again.
Acceleration control formula: a=-kv
%}
function [numSteps, totalTime, closingVelocity ] = ...
dockingSimulation(closingVelocity, k, adjustmentTime, revisitTime)
%% ----------------------------------------------------
global excelOut
% Create our spreadsheet headers
fprintf(excelOut, 'Step #, Beginning Time (sec), End Time (sec), Velocity (m/sec)\n'); % Header line
numSteps = 0;
totalTime = adjustmentTime;
while( abs(closingVelocity) > .1 )
fprintf(excelOut,' %2.0f, %5.1f, %5.1f, %6.4f,\n' ...
, numSteps, totalTime, totalTime+15, closingVelocity);
deltaVelocity = 15 * (-k) * closingVelocity;
closingVelocity = closingVelocity + deltaVelocity;
totalTime = totalTime + adjustmentTime + revisitTime;
numSteps = numSteps + 1;
end
% Adjust our steps
fprintf(excelOut,' %2.0f, %5.1f, %5.1f, %6.4f,\n' ...
, numSteps, totalTime, totalTime+15, closingVelocity);
end