-
Notifications
You must be signed in to change notification settings - Fork 0
/
visible_area_trend.m
97 lines (86 loc) · 2.75 KB
/
visible_area_trend.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
% Change in visible area of sphere with distance
%
% Written by Vinay
%
% Started on : 22nd November 2021
%
% Last Modified: 1st Feruary 2022
%
% Description:
%
% Calculate the trend in visible area of a spherical body as distance
% between it and the observer changes
%
% Mandatory Inputs:
% flag_plot - boolean (true/false)
% Specifies whether to plot trend or not
%
% Optional Inputs:
%
% radius - Requires two values to be passed in
% * 1st is numeric value for the radius of the observed body
% * 2nd is a string representing the name of the body
%
% unit - requires two values to be passed
% * 1st is a numeric value for the unit of distance to use
% for plotting
% * 2nd is a string value for the label for the unit to use
% on the plots
%
% distance - maximum simulation distance
%
% interval - interval to simulate distance at
%
% Outputs:
%
% area - matrix with area values
%
% dist - matrix with distance values from observed body
%
function [dist, area] = visible_area_trend(flag_plot, varargin)
radius = 696340; % Radius of observed body (default = sun)
unit = 147.72e6; % Unit length (default = 1 astronomical unit)
distance = 147.72e6; % Maximum simulation distance (default = 1 AU)
interval = 10; % Simulation interval (default = 10)
dist = 0:(distance/interval)-1; % Array for distance values
area = dist; % Array for area values
name = "Solar";
units = "Au";
% Process Arguments
n = 1;
while n < size(varargin,2)
strval = lower(varargin{n});
switch strval
case "radius"
n=n+1;
radius = varargin{n}; %#ok<NASGU>
n=n+1;
name = varargin{n};
case "unit"
n=n+1;
unit = varargin{n};
n=n+1;
units = varargin{n};
case "distance"
distance = varargin{n};
case "interval"
n=n+1;
interval = varargin{n};
end
n=n+1;
end
% Calculation loop
for h = interval:interval:distance
dist(h/interval) = h;
area(h/interval) = visible_area(radius, h);
end
if flag_plot == true
figure(1);
set(gca,'FontSize',18, "fontname", "times")
hold on;
plot(dist./unit, area,"--.", 'color', 'black')
xlabel("Distance from Surface ["+units+"]");
ylabel("Visible "+name+" Area [km^2]");
title("Visible "+name+" surface from 0 to " + dist(length(dist))/unit+units)
end
end