Effacer les filtres
Effacer les filtres

Find the row and col of array?

1 vue (au cours des 30 derniers jours)
Tara
Tara le 22 Avr 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

Réponse acceptée

Image Analyst
Image Analyst le 22 Avr 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 commentaires
Walter Roberson
Walter Roberson le 22 Avr 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 le 22 Avr 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).

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Desktop dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by