reorder data in a matrix
Ältere Kommentare anzeigen
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 Kommentare
"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
am 26 Feb. 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
am 26 Feb. 2023
Image Analyst
am 26 Feb. 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.
Akzeptierte Antwort
Weitere Antworten (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 Kommentar
barath manoharan
am 26 Feb. 2023
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!