필터 지우기
필터 지우기

How to pick out the corresponding answers

조회 수: 1 (최근 30일)
zhe li
zhe li 2013년 2월 7일
Dear All,
Thank you for your time.
I would want to find the corresponding answers after comparing a main result.
This is the example:
I am comparing a calculated result A= 2 5 3 9 1 10 and 1 is the smallest value and B= 2 5 7 4 9 5 and C= 5 2 4 7 6 1 are the answers related to A, since smallest A is 1, I would want to pick out the corresponding answers which should be B=9 and C=6. However, I have tried in different ways, I still cannot achieve it. Could somebody help me with this please?
Thank you very much.
Zhe Li

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 7일
편집: Azzi Abdelmalek 2013년 2월 7일
A=[2 5 3 9 1 10]
B=[2 5 7 4 9 5]
C=[5 2 4 7 6 1]
[x,idx]=min(A) % x is the min value and idx is the corresponding index
out1=B(idx)
out2=C(idx)
  댓글 수: 8
Thorsten
Thorsten 2013년 2월 7일
Dear Zhe Li,
please tell us the output of
whos a
with a replaced by the name of the real variable. Matlabs variables can belong to different classes, e.g, double, or cell, and depending on what the class is you may need different functions to solve your problem.
zhe li
zhe li 2013년 2월 8일
Hi Azzi,
Thank you so much for your answer, it works.
Zhe Li

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

추가 답변 (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