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

4 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Chunru
Chunru el 23 de Sept. de 2021
[i,j] = find(abs(a-23.5975)<1e-20)
  7 comentarios
Walter Roberson
Walter Roberson el 23 de Sept. de 2021
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by