How can I do linear indexing in matlab?
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (4)
Abdulrazzaq
le 1 Mar 2014
Modifié(e) : Abdulrazzaq
le 1 Mar 2014
try:
B = A(:)';
Best wishes
Abdulrazzaq
dpb
le 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
le 1 Mar 2014
0 votes
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 commentaire
TAUSIF
le 2 Mar 2014
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!