How can I do linear indexing in matlab?
Mostra commenti meno recenti
hi, Suppose I have a matrix A=[1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]; I want to transfer it into a linear matrix as A=[1 2 5 6 3 4 7 8 9 10 13 14 11 12 15 16]; (i.e. mortan scan order in image processing). Can you help me. All my work will start after this only. I would be very greatful to you
Risposta accettata
Più risposte (4)
Abdulrazzaq
il 1 Mar 2014
Modificato: Abdulrazzaq
il 1 Mar 2014
try:
B = A(:)';
Best wishes
Abdulrazzaq
dpb
il 1 Mar 2014
One way amongst many --
B=reshape(reshape(A.',2,[]),1,[]);
Consider how Matlab storage is in column-major order and what operation one needs to get to the desired organization from the original...
Roger Stafford
il 1 Mar 2014
0 voti
If you convert each of the integers 0:15 to binary, permute the digits appropriately, recalculate the numbers from these permuted digits, and finally add 1 to each, you will get the correct linear indexing. The same holds true for larger Z-orders.
1 Commento
TAUSIF
il 2 Mar 2014
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!