how to find y axis value's opposite x axis value

조회 수: 3 (최근 30일)
skyhunt
skyhunt 2015년 4월 29일
댓글: KL 2015년 4월 29일
for ex:x=1,2,3,4,5,6;y=2,7,8,9,4,1 i want pick up the y axis (9) opposite x axis value

채택된 답변

KL
KL 2015년 4월 29일
If both vectors are of same size, find the index of your variable from y and use it to pick the value at that position in x. A simple example is
x = [1 2 3 4];
y = [5 6 7 8];
ind = find(y==7);
x(ind);
  댓글 수: 2
Stephen23
Stephen23 2015년 4월 29일
편집: Stephen23 2015년 4월 29일
Using logical indexing (as per Ilham Hardy's answer) is simpler and faster than using find.
KL
KL 2015년 4월 29일
agreed.

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

추가 답변 (1개)

Ilham Hardy
Ilham Hardy 2015년 4월 29일
>> x=[1,2,3,4,5,6];
>> y=[2,7,8,9,4,1];
>> opp_x = x(y==9)
opp_x =
4

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by