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

4 次查看(过去 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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by