필터 지우기
필터 지우기

Arrays sorting

조회 수: 1 (최근 30일)
athpapa -
athpapa - 2011년 3월 5일
Hello,
I have 2 arrays: A=[3 5 11] and B=[2 3 0]. I multiply these 2 arrays and I produce a third: C=times(A,B)=[6 15 0]. I sort array C in descent order D=sort(C,'descend')=[15 6 0]. How can I sort and the arrays A and B to match with array D? I mean I want array A to take this order:A=[5 3 11] and array B=[3 2 0]. But, I want this function to work for random arrays and not only for the example!
Thank you...

채택된 답변

Jan
Jan 2011년 3월 5일
A = [3 5 11]
B = [2 3 0]
C = times(A, B);
[D, Index] = sort(C);
AA = A(Index)
BB = B(Index)
  댓글 수: 1
athpapa -
athpapa - 2011년 3월 5일
thank you!!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by