forked from jsdaiustc/Fault_frequency_learning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_Pm.m
65 lines (45 loc) · 1.18 KB
/
search_Pm.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
function [Fn,unactive]=search_Pm(Pm,f_sample)
unactive=0;
[~,ind]=sort(Pm,'descend');
Num=min(10,length(Pm));
F_active= f_sample(ind(1:Num));
%% remove closed values;
for ii=1:Num
F_choose = F_active(ii);
for jj=ii+1:Num
if abs(F_active(jj)-F_choose)< 10
F_active(jj)=0;
end
end
end
F_active(F_active==0)=[];
Num=length(F_active);
%% chose the optimal ind
Z=zeros(Num,Num);
C=zeros(Num,Num);
for ii=1:Num
F_choose = F_active(ii);
for jj=1: Num
modmod= mod(F_active(jj),F_choose);
if min(modmod, abs(F_choose-modmod) ) < min(5, F_choose*0.05) && F_active(jj)/F_choose<=10
Z(ii,jj)=1;
C(ii,jj)= round(F_active(jj)/F_choose);
end
end
end
[Z_max,Z_ind]=max(sum(Z,2));
%%
z_choose=Z(Z_ind,:);
c_choose=C(Z_ind,:);
F_res=F_active(z_choose==1);
C_res=c_choose(z_choose==1);
Fn=sum(F_res)/sum(C_res);
if Z_max<=1
unactive=1;
elseif Z_max==2
ind11= find(z_choose==1);
if abs(ind11(1)-ind11(2))>5
unactive=1;
end
end
end