How to find same values in an array and their index
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have array with some repeated values. I have 1e-6 repeatedly. How can I have find all the values and their corresponding index?
0 commentaires
Réponses (1)
Dyuman Joshi
le 13 Nov 2023
Déplacé(e) : Dyuman Joshi
le 13 Nov 2023
arr = load('array.mat')
mat = arr.yintercept
val = 1e-6;
%As you are dealing with floating point numbers, use tolerance to compare
[r, c] = find(abs(mat-val)<1e-9)
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!