Sorting and averaging matrices

1 ビュー (過去 30 日間)
HT 2019 年 9 月 9 日
コメント済み: Matt J 2019 年 9 月 16 日
  1. I have two matrices. One for example is A = 520 x 1 and it has numbers from 1-8 which are not in order. For every number in this matrix, I have corresponding 1000 samples in another matrix B 520 x 1000. I want to first sort A and arrange numbers from 1-8 for every 8 rows. So output should be (1,2,3,4,5,6,7,8,1,2,3,4,5 and so on) and arrange corresponding values in B also such that they match.
  2. Once this is done, I want to average every 5 rows of B and store it in a new matrix which will be 104 x 1000.
Thanks for the help in advance!
  4 件のコメント
HT 2019 年 9 月 9 日
It will be a multiple of 8 always. I just took 100 as a random number. I will edit the main question, thank you.



Matt J
Matt J 2019 年 9 月 9 日
編集済み: Matt J 2019 年 9 月 10 日
[~,idx]=sort( reshape(A,8,[]) ,1);
result=reshape( C ,m*n/5,[]);
  8 件のコメント
Matt J
Matt J 2019 年 9 月 16 日
[Asorted,idx]=sort( reshape(A,8,[]) ,1);


その他の回答 (0 件)



Community Treasure Hunt

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

Start Hunting!

Translated by