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!