Select an element of variable. HELP.
조회 수: 1 (최근 30일)
이전 댓글 표시
i have centroids
A = [78 124;209 125];
B = [80 127;212 134];
i want to select the element in B which is closest to an element in A. for example B1 is the element of B that closest to A(1,:) and B2 is the element of B that closest to A(2,:)
thx sorry for my poor question, im new to matlab.
댓글 수: 0
답변 (1개)
Rick Rosson
2012년 4월 18일
N = numel(B);
x = zeros(N,1);
for k = 1:N
x(k) = min(abs(A(:) - B(k)));
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!