-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcalculateTotalRRwSeeAndAvoid.m
77 lines (59 loc) · 1.84 KB
/
calculateTotalRRwSeeAndAvoid.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
function [rr]= calculateTotalRRwSeeAndAvoid(inSpeedVect,inRrVect,inRrVectSAA,daaSpec)
%Calculates cumulative RR factoring in See and Avoid
myBins = [5:10:295];
%These values determined based on curve interpolation
myNormDist = [ 0.001405667692905
0.001405667692905
0.001405667692905
0.003987547931244
0.009674291907117
0.026095698944210
0.051832146169262
0.090691356469433
0.132072989243198
0.141405408062189
0.135374611044511
0.107715315615124
0.084529105141218
0.063002617885127
0.045538631401297
0.033246626287672
0.024041374204839
0.016159996583123
0.010047998179908
0.007391314924999
0.004326616198941
0.002667935337829
0.002126145203992
0.001746768646695
0.001405667692905
0.001405667692905
0
0
0
0]';
%% If you want to Plot...uncomment this
%Plot results
% figure
% bar(myBins,myNormDist);
% xlabel('Airspeed (kts)')
% ylabel('Prob Density')
% title('Airspace Distribution by Speed (10 kt bins)')
% grid;
%Build the pass/fail #'s
% Memory Allocation
passHeight = zeros(1,length(inSpeedVect));
failHeight = zeros(1,length(inSpeedVect));
saaHeight = zeros(1,length(inSpeedVect)); % this is the height of the see and avoid portion
for i=1:length(inSpeedVect)
binDist = interp1(myBins,myNormDist,inSpeedVect(i),'nearest'); % This is the overall prob dis of the current speed bin
failHeightNoSee = binDist*inRrVect(i); % Not counting see and avoid
passHeightNoSee = binDist - failHeightNoSee;
failHeight(i) = binDist*inRrVectSAA(i);
saaHeight(i) = binDist - failHeight(i) - passHeightNoSee;
passHeight(i) = binDist - failHeightNoSee;
end % for
passCumSum = cumsum(passHeight);
failCumSum = cumsum(failHeight);
saaCumSum = cumsum(saaHeight);
rr=failCumSum(end);