필터 지우기
필터 지우기

How to match two arrays with its index and extract the value ?

조회 수: 2 (최근 30일)
Aswin Sandirakumaran
Aswin Sandirakumaran 2018년 4월 8일
댓글: David Fletcher 2018년 4월 8일
For Eg:
B = [ 60,600,15];
C = [10^(-4),10^(-9),10^(-7)];
Here we need to look for the minimum value in the array C and once done match its index with array B and display the value ( which in this case will be 600). And this should be done in loop And the Output should look something like this
O = [600,15,60];
  댓글 수: 1
David Fletcher
David Fletcher 2018년 4월 8일
The quirkiness of the problem, and the stipulation of using a loop makes this sound a bit like homework. Even if it's not, you should at least make some effort of creating a solution of your own. If you then have problems with things that don't work, come back and ask further questions. That's how people learn.

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

답변 (1개)

Birdman
Birdman 2018년 4월 8일
Simply do this:
[~,idx]=sort(C,'ascend')
O=B(idx)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by