-
Notifications
You must be signed in to change notification settings - Fork 0
/
findHighProductionSS.m
55 lines (42 loc) · 1.43 KB
/
findHighProductionSS.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
% this script finds the highest producing sea states on an yearly based by
% accounting for the probability of occurance
percentile = 0.5; % percentile for set of sea states to meet
nSS = length(Tp);
nRandNums = 10;
PP_peak = max(PP_w_data,[],2)';
PP_peakWeighted = weight/100.*PP_peak;
[PP_sorted, I_sorted] = sort(PP_peakWeighted);
lowerPercentileIndex = ceil(percentile*nSS);
selection = randomSelection(I_sorted(lowerPercentileIndex:end),nRandNums)
figure
scatter(1:nSS,PP_peak/max(PP_peak))
hold on
scatter(1:nSS,PP_peakWeighted/max(PP_peakWeighted))
xlabel('sea state index')
ylabel('normalized quantity')
legend('optimal power absorption','weighted optimal power absorption')
figure
plot(1:nSS,PP_peak/max(PP_peak),'-xk')
hold on
plot(1:nSS,PP_peakWeighted/max(PP_peakWeighted),'-xr')
xlabel('sea state index')
ylabel('normalized quantity')
legend('optimal power absorption','weighted optimal power absorption')
xlim([1 nSS])
cum_PP_sorted = cumtrapz(PP_sorted);
figure
plot(PP_sorted/max(PP_sorted))
hold on
plot(cum_PP_sorted/max(cum_PP_sorted))
function randNums = randomSelection(numSet,nRandNums)
randNums = [];
nNums = length(numSet);
for i = 1:nRandNums
% pick random number for set
numSetIndex = floor(rand*nNums+1);
randNums = cat(1,randNums,numSet(numSetIndex));
% remove picked number from set
numSet(numSetIndex) = [];
nNums = length(numSet);
end
end