필터 지우기
필터 지우기

how to sort a array with 100 values. and also save there index also?

조회 수: 2 (최근 30일)
preet
preet 2013년 5월 1일
답변: Swaroopa 2022년 8월 28일
i have a problem regarding sorting.... for example
a=[14,3,65,78,98,1];
here
a[1]=14 after sorting its index will be change i.e 3 but i want to save the
previous index values 1 simultaneously mean original index before sorting?
  댓글 수: 3
preet
preet 2013년 5월 1일
but i required logic without using directly sort() function

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

답변 (1개)

Swaroopa
Swaroopa 2022년 8월 28일
Hi Preet,
You can use map() function to store previous indices of elements in array and then sort the arrray.
You can refer Sort vector using loops - MATLAB Answers - MATLAB Central (mathworks.com) for sorting a vector without using builtin functions i.e. by using loops.
Refer to the below documentation for more information:
Hope it helps.

카테고리

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