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 日
thanx dear.
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 Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by