Effacer les filtres
Effacer les filtres

Finding Of Same Values in Matrix

2 vues (au cours des 30 derniers jours)
Volkan Yangin
Volkan Yangin le 6 Déc 2015
Commenté : Volkan Yangin le 6 Déc 2015
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..

Réponse acceptée

Image Analyst
Image Analyst le 6 Déc 2015
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 commentaire
Volkan Yangin
Volkan Yangin le 6 Déc 2015
Thank you for answer, Image Analyst.

Connectez-vous pour commenter.

Plus de réponses (1)

Andrei Bobrov
Andrei Bobrov le 6 Déc 2015
a - your array;
b = unique(a);
[~,idx] = ismember(a,b);
  1 commentaire
Volkan Yangin
Volkan Yangin le 6 Déc 2015
Thank you, Andrei Bobrov.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by