필터 지우기
필터 지우기

How to Find a Value From Another Value?

조회 수: 3 (최근 30일)
Rafael
Rafael 2017년 12월 7일
댓글: Rafael 2017년 12월 7일
I have a matrix, so I would like to find a value from the first column by using values from the last columns. For example, I have an specific value from the last column which I found by suing "find". How can I then find the value from the first column from that specific row by using the last column value?

채택된 답변

Birdman
Birdman 2017년 12월 7일
One approach:
A=[1 2 3;4 5 6;7 8 9];
[r,c]=find(A==9);
value=A(r,1)
  댓글 수: 3
Birdman
Birdman 2017년 12월 7일
What did you want ?
Rafael
Rafael 2017년 12월 7일
I got it working. I only had to use your last line code. I had it like this, Value=find(A(r,1))

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

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2017년 12월 7일
편집: Andrei Bobrov 2017년 12월 7일
A = reshape(1:16,4,[]); % Let A - your array (example)
out = A(A(:,end) == 14,1)
  댓글 수: 2
Rafael
Rafael 2017년 12월 7일
Can you explain to me what exactly does these codes do? I mean, 1:16 I understand, but the other things I don't.
Andrei Bobrov
Andrei Bobrov 2017년 12월 7일
A = reshape(1:16,4,[]);
It's example of your array.

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by