Finding location of specific element from a MATRIX returns '0×1 empty double column vector'

15 ビュー (過去 30 日間)
Hi everyone,
I have a matrix and I'm trying to find location of some specific elements but it gives me no answer. My code:
[i,j] = find(a==23.5975) % it can be clearly seen in the figure that this value is present in the
% 1st row and 3rd column. but it gives the following result.
i =
0×1 empty double column vector
j =
0×1 empty double column vector
I'll be gratefu for any help, thank you.

採用された回答

Chunru
Chunru 2021 年 9 月 23 日
[i,j] = find(abs(a-23.5975)<1e-20)
  7 件のコメント
Walter Roberson
Walter Roberson 2021 年 9 月 23 日
target = 0.1863
target = 0.1863
rng(1);
a = rand(4)
a = 4×4
0.4170 0.1468 0.3968 0.2045 0.7203 0.0923 0.5388 0.8781 0.0001 0.1863 0.4192 0.0274 0.3023 0.3456 0.6852 0.6705
[found, idx] = ismembertol(target, a)
found = logical
0
idx = 0
[~, minidx] = min(abs(target - a(:)));
a(minidx)
ans = 0.1863
a(minidx) - target
ans = -3.9789e-05
[found, idx] = ismembertol(target, a, 1e-4)
found = logical
1
idx = 7
Zhou Ci
Zhou Ci 2021 年 9 月 23 日
Working now, Thanks alot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDetection についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by