reorder data in a matrix
古いコメントを表示
i have a 7*1 double matrix and need to reorder data to satisfy some condition.Thank you in advance.
example:
Let A = [10010 ; 11000 ; 01100 ; 01011 ; 10111 ; 11010 ; 01111]
output :
B = [10010 ; 11010 ; 11000 ; 01100 ; 01111 ; 01011 ; 10111]
5 件のコメント
"i have a 7*1 double matrix and need to reorder data to satisfy some condition"
And what exactly is that condition?
A = [1,0,0,1,0; 1,1,0,0,0; 1,1,0,1,0; 0,1,1,0,0; 0,1,0,1,1];
A * pow2(4:-1:0).'
B = [1,0,0,1,0; 1,1,0,1,0; 1,1,0,0,0; 0,1,0,1,1; 0,1,1,0,0];
B * pow2(4:-1:0).'
barath manoharan
2023 年 2 月 26 日
"since i want the number of bit changes between consecutive pattern to be minimum and when totalled it will be least."
Please give a precise mathematical description of how to calculate the "minimum" and also how to "total" them. There are many such norms that could be applied, I have no idea which one you want to use.
barath manoharan
2023 年 2 月 26 日
Image Analyst
2023 年 2 月 26 日
This looks like a homework problem. Is it? If so, ask your instructor or read the link below to get started:
Obviously we can't give you the full solution because you're not allowed to turn in our code as your own.
採用された回答
その他の回答 (1 件)
It seems to me that you want this logic implemented:
A = ["10010" ; "11000" ; "11010" ; "01100" ; "01011"]
N = numel(A);
B = A;
for i = N:-2:2
B([i,i-1]) = B([i-1,i]);
end
B
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!