필터 지우기
필터 지우기

Find the row and col of array?

조회 수: 1 (최근 30일)
Tara
Tara 2013년 4월 22일
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개)

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by