Borrar filtros
Borrar filtros

Find the row and col of array?

1 visualización (últimos 30 días)
Tara
Tara el 22 de Abr. de 2013
i have an array
A=[0.9784 0.0102 0.0045;0.0085 0.9784 0.0730;0.9673 0.0156 0.0063];
before i get A, i create A = zeros(numTest,numLabels);
i want to find the row and col,i try
co=find(A==0.9784)
but it result Empty matrix: 0-by-1. what should i do? Thank you

Respuesta aceptada

Image Analyst
Image Analyst el 22 de Abr. de 2013
You should read the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F After that, if you still don't understand, write back.
  3 comentarios
Walter Roberson
Walter Roberson el 22 de Abr. de 2013
You don't. That value, 0.9784, does not exist in the matrix. At the command line, give the command
format long g
and then
disp(A(1))
and
disp(A(1)-0.9784)
Image Analyst
Image Analyst el 22 de Abr. de 2013
Try this:
[rows, columns] = find(abs(A-0.9784) < 0.00009)
In the command window:
A =
0.9784 0.0102 0.0045
0.0085 0.9784 0.073
0.9673 0.0156 0.0063
rows =
1
2
columns =
1
2
So the value happens at (1,1) and (2,2).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Desktop 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