-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplotRrBinPassFailChart.m
93 lines (76 loc) · 2.43 KB
/
plotRrBinPassFailChart.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
function plotRrBinPassFailChart(inSpeedVect,inRrVect,daaSpec)
%Plots a stacked bar chart of the Pass/Fail RR normalized so the sum of the bars == the distribution of that traffic speed in the airsapce
myBins = [5:10:295];
%These values determined based on curve interpolation as detailed in airspaceDistBuilder.m
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));
for i=1:length(inSpeedVect)
binDist = interp1(myBins,myNormDist,inSpeedVect(i),'nearest'); % This is the overall prob dis of the current speed bin
failHeight(i) = binDist*inRrVect(i);
passHeight(i) = binDist - failHeight(i);
end % for
%%
figure
subplot(2,1,1) %Plot of each bin pass/fail
bar(inSpeedVect, [failHeight; passHeight]','stacked');
colormap(hot); % Maybe tweak these
myTitleLine1 = sprintf('RR %d kts ownship, %d deg Bank', daaSpec.ownSpeed_kts,daaSpec.maxBank_deg);
myTitleLine2 = sprintf('No See & Avoid');
title({myTitleLine1 myTitleLine2});
xlabel('Intruder Speed (kts)');
ylabel('Normalized Probability')
legend('Fail','Pass:Detect');
grid on;
%Now let's do a cumulative stacked bar chart
subplot(2,1,2)
passCumSum = cumsum(passHeight);
failCumSum = cumsum(failHeight);
bar(inSpeedVect, [failCumSum; passCumSum]','stacked');
colormap(hot); % Maybe tweak these
xlabel('Intruder Speed (kts)');
ylabel('Cumulative Probability')
grid on
hold on
plot([inSpeedVect(1) inSpeedVect(end)],[failCumSum(end) failCumSum(end)],'--k'); % PLot the RR Line
text(inSpeedVect(1),failCumSum(end)+0.1,['RR=' num2str(failCumSum(end),2)]);
hold off