Index of a matrix?

조회 수: 1 (최근 30일)
Robin
Robin 2011년 7월 31일
I have two column matricies x and y (neither of them have repeating numbers). I want to search for a number in matrix x, get the index and get the number of that index in matrix y. This seems simple enough to do, but I am still not that familiar with matlab. Can someone help me out please?
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 7월 31일
This post requires merging with: http://www.mathworks.com/matlabcentral/answers/12768-i-cannot-find-the-index-of-a-specific-element-in-an-array.

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2011년 7월 31일
index = (x==A); % A is the number you want to find in x.
y(index)
You would probably benefit from spending some time here: http://www.mathworks.com/help/techdoc/learn_matlab/bqr_2pl.html
  댓글 수: 2
Robin
Robin 2011년 7월 31일
yes this does help me, but I've run into another problem. Say I am looking for the element 1.5 in array x. I tried ind=find(x==1.5), but it doesnt work. I am absolutely sure 1.5 is in array x.
Andrei Bobrov
Andrei Bobrov 2011년 7월 31일
see: <http://www.mathworks.com/matlabcentral/answers/12768-i-cannot-find-the-index-of-a-specific-element-in-an-array>
eg:
ind = find(abs(x - 1.5) < 100*eps)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by