Removing Duplicate Elements from Array sets

조회 수: 938 (최근 30일)
Ruchit Pathak
Ruchit Pathak 2013년 5월 13일
I am constructing a genetic algorithm for finding optimal solution of a problem. The population used consists of three controller parameters (Kp Ki Kd)and fitness value. If the values of [Kp Ki Kd] are repeated the chances of finding a wrong solution due to premature conversion is high. So i want to check if there are any duplicate entries for [Kp Ki Kd] and remove them.
NOTE: I only want to remove if all the three [Kp Ki Kd] are same.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 5월 13일
Let your array: K = [Kp Ki Kd]
Knew = K(any(diff(K,1,2),2),:);

추가 답변 (1개)

David Sanchez
David Sanchez 2013년 5월 13일
Use unique command:
M = [1 2 3; 4 5 6;1 2 3; 1 2 3; 6 7 8];
A = unique(M,'rows')

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by