How to find same values in an array and their index
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Dyuman Joshi
2023-11-13
移动:Dyuman Joshi
2023-11-13
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!