reorder data in a matrix
Mostrar comentarios más antiguos
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 comentarios
"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
el 26 de Feb. de 2023
"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
el 26 de Feb. de 2023
Image Analyst
el 26 de Feb. de 2023
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.
Respuesta aceptada
Más respuestas (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
1 comentario
barath manoharan
el 26 de Feb. de 2023
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!