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

6 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Chunru
Chunru il 23 Set 2021
[i,j] = find(abs(a-23.5975)<1e-20)
  7 Commenti
Walter Roberson
Walter Roberson il 23 Set 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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by