Clear Filters
Clear Filters

Find the row and col of array?

1 view (last 30 days)
Tara
Tara on 22 Apr 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

Accepted Answer

Image Analyst
Image Analyst on 22 Apr 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 Comments
Walter Roberson
Walter Roberson on 22 Apr 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 on 22 Apr 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).

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!