필터 지우기
필터 지우기

How to select a row vector with maximum fitness value if few of vectors are restricted to consider?

조회 수: 1 (최근 30일)
I want to select a row vector ‘NS’ with maximum ‘newResultTF’ value when some of these row vectors are not considered for evaluation which appears in a certain list ‘TM’.
For example, I have a five row vectors under variable ‘NS’
NS(:,:,1) = 6 1 1 1 1
NS(:,:,2) = 5 3 1 1 1
NS(:,:,3) = 5 1 8 1 1
NS(:,:,4) = 5 1 1 3 1
NS(:,:,5) = 5 1 1 1 7
And their fitness values are under variable ‘newResultTF’
newResultTF(:,:,1) = 104
newResultTF(:,:,2) = 101
newResultTF(:,:,3) = 95
newResultTF(:,:,4) = 103
newResultTF(:,:,5) = 89
Restricted row vector are under variable ‘TM’
TM(:,:,1) = 6 1 1 1 1
TM(:,:,2) = 5 1 8 1 1
Now I want to select row vector ‘NS’ with maximum ‘newResultTF’ value except vectors in ‘TM’. For example in this case the selected vector is
NS(:,:,4) = 5 1 1 3 1
With maximum ‘newResultTF’ value
newResultTF(:,:,4) = 103
Please help. Thanks in anticipation!

채택된 답변

KSSV
KSSV 2017년 3월 10일
NS(:,:,1) = [6 1 1 1 1];
NS(:,:,2) = [5 3 1 1 1];
NS(:,:,3) = [5 1 8 1 1];
NS(:,:,4) = [5 1 1 3 1];
NS(:,:,5) = [5 1 1 1 7];
NS = squeeze(NS)' ;
newResultTF(:,:,1) = 104 ;
newResultTF(:,:,2) = 101 ;
newResultTF(:,:,3) = 95 ;
newResultTF(:,:,4) = 103 ;
newResultTF(:,:,5) = 89 ;
maxdata = squeeze(newResultTF)' ;
[val,id] = sort(maxdata,'descend') ;
TM(:,:,1) = [6 1 1 1 1] ;
TM(:,:,2) = [5 1 8 1 1] ;
TM = squeeze(TM)' ;
for i = 1:length(maxdata)
if ~ismember(NS(id(i),:),TM,'rows')
iwant = NS(id(i),:) ;
break
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by