Find the row and col of array?

1 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2013-4-22
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 个评论
Walter Roberson
Walter Roberson 2013-4-22
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 2013-4-22
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).

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by