Convert 1d matrix to 2d using zigzag ordering

I have a 1D matrix in MATLAB, which, created with the best answer of the question mentioned below, I would like to reorder it in the first array:

Zigzag Matrix Ordering

zigzag layout pattern Source: Wikidpedia: Jpeg

m = [69     9    75    46    23    16   100    83    92    54     8    45];

zigzag_writing(m, 4, 3)

ANS =

69     9    16   100
75    23    83     8
46    92    54    45
+4
source share
1 answer

You can find invzigzagwhen sharing files Matlab.

>> invzigzag(m,3,4)

ans =

    69     9    16   100
    75    23    83     8
    46    92    54    45
+1
source

All Articles