필터 지우기
필터 지우기

Finding Of Same Values in Matrix

조회 수: 2 (최근 30일)
Volkan Yangin
Volkan Yangin 2015년 12월 6일
댓글: Volkan Yangin 2015년 12월 6일
Hi everbody
I have a matrix includes 1724 values, i want to find which elements are same in this matrix (For ex. 25. and 426. values are same etc.)
How can i make this?
Thanks..

채택된 답변

Image Analyst
Image Analyst 2015년 12월 6일
What about using unique and a brute force approach:
m = randi(10, 1, 100) % Sample data.
allValues = unique(m); % Find unique numbers.
for k = 1 : length(allValues)
thisValue = allValues(k);
indexes{k} = find(m == thisValue);
fprintf('The number %f is found at indexes : ', thisValue);
fprintf('%d ', indexes{k});
fprintf('\n');
end
% celldisp(indexes)
  댓글 수: 1
Volkan Yangin
Volkan Yangin 2015년 12월 6일
Thank you for answer, Image Analyst.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2015년 12월 6일
a - your array;
b = unique(a);
[~,idx] = ismember(a,b);
  댓글 수: 1
Volkan Yangin
Volkan Yangin 2015년 12월 6일
Thank you, Andrei Bobrov.

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by