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!