-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsim_menu.m
More file actions
82 lines (54 loc) · 2.46 KB
/
Copy pathsim_menu.m
File metadata and controls
82 lines (54 loc) · 2.46 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function sim_menu()
clc;
global THRUST_ON SIM_MODE SIM_TIME SC_POS
% Asks if thrust is active
thrust_choice = menu('Is there thrust on the asteroid?', 'Yes', 'No');
if thrust_choice == 0
error('No selection made. Simulation cancelled.');
end
if thrust_choice == 1
THRUST_ON = true;
% Thrust is ON: Ask how to run simulation
sim_choice = menu('Choose simulation condition:','Run until fuel runs out', 'Run for a specified time');
if sim_choice == 0
error('No selection made. Simulation cancelled.');
end
SIM_MODE = sim_choice;
if sim_choice == 2
answer = inputdlg('Enter total simulation time (seconds):', 'Simulation Duration', [1 35], {'631152000'});
if isempty(answer)
error('Simulation cancelled');
end
SIM_TIME = str2double(answer{1});
if isnan(SIM_TIME) || SIM_TIME <= 0
error('Invalid simulation time');
end
disp(['Running simulation with thrust for ', num2str(SIM_TIME), ' seconds...'])
end
ans_infront = menu("Where is the Spacecraft Relative to the Asteroid's motion:", 'In Front (ahead)', 'Behind (trailing)');
if ans_infront == 0
error('No selection made. Simulation cancelled.');
end
SC_POS = (ans_infront == 2); % true if behind
elseif thrust_choice == 2
THRUST_ON = false;
disp('Running simulation without thrust...');
ans_infront = menu("Where is the Spacecraft Relative to the Asteroid's motion:", 'In Front (ahead)', 'Behind (trailing)');
if ans_infront == 0
error('No selection made. Simulation cancelled.');
end
SC_POS = (ans_infront == 2); % true if behind
SIM_MODE = 2;
if SIM_MODE == 2
answer = inputdlg('Enter total simulation time (seconds):', 'Simulation Duration', [1 35], {'3.156e+7'});
if isempty(answer)
error('No input provided. Simulation cancelled.');
end
SIM_TIME = str2double(answer{1});
if isnan(SIM_TIME) || SIM_TIME <= 0
error('Invalid simulation time');
end
disp(['Running simulation with thrust for ', num2str(SIM_TIME), ' seconds...']);
end
end
end