Sorting values according to index

I have two vales
S=[70 110 65 30 25 40 60]
K=[4 2 3 1 5 7 6];
I have to sort S according to K for example 70 must be 1n 4th position 110 must be in 2nd position ,so on
X=[30 110 65 70 25 60 40],please assist

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 29 日
編集済み: Azzi Abdelmalek 2012 年 11 月 29 日

1 投票

S=[70 110 65 30 25 40 60]
K=[4 2 3 1 5 7 6];
[~,idx]=sort(K);
out=S(idx)

6 件のコメント

kash
kash 2012 年 11 月 29 日
Thanks Azzi final question
I have performed
D1=int16(cA*32768);cA varies from -1 to 1
D2=max(min(round(2^13*sA),2^13),-2^13);sa varies from -1 to 1
performed several operation on D1,D2
now how to rescale D1,D2 in range -1 to 1
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 29 日
what is sA?
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 29 日
編集済み: Azzi Abdelmalek 2012 年 11 月 29 日
cA=0.2
D1=int16(cA*32768)/8192;
D2=max(min(round(2^13*cA),2^13),-2^13)/8192,
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 29 日
I don't know, never worked with dwt
kash
kash 2012 年 11 月 29 日
Azzi my values in D1 ranges from -4 to 4 after performing
D1=int16(cA*32768)/8192;
where as i need from -1 to 1
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 29 日
then use
D1=int16(cA*32768)/32767

サインインしてコメントする。

その他の回答 (1 件)

Ilham Hardy
Ilham Hardy 2012 年 11 月 29 日

0 投票

X = S(K)

カテゴリ

ヘルプ センター および 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