How to reshape a matrix horizontally using MATLAB -



How to reshape a matrix horizontally using MATLAB -

i have matrix a of size(4,192). consists of 12 matrices of size(4,4) aligned horizontally. want matrix b size(12,16). b must follows: suppose

a=[y1,y2,y3,...,y12]

in yn 4*4 matrix. then,

b=[y1,y4,y7,y10; y2,y5,y8,y11; y3,y6,y9,y12]

is there efficient/quicker (using no loop) way using matlab?

you can seek next code:

ys1 = 2; % size(1) submatrix (for next example, utilize ys1 = 4 actual problem) ys2 = 2; % size(2) submatrix (for next example, utilize ys2 = 4 actual problem) ns1 = 3; % size(1) of final matrix in terms of submatrix (3 rows) ns2 = 4; % size(2) of final matrix in terms of submatrix (4 columns) temp = reshape(a,ys1,ys2,ns1,ns2); b = reshape(permute(temp,[1 3 2 4]),ys1*ns1,ys2*ns2);

example:

a = [11 12 21 22 31 32 41 42 51 52 61 62 71 72 81 82 91 92 101 102 111 112 121 122; 13 14 23 24 33 34 43 44 53 54 63 64 73 74 83 84 93 94 103 104 113 114 123 124]; b = 11 12 41 42 71 72 101 102 13 14 43 44 73 74 103 104 21 22 51 52 81 82 111 112 23 24 53 54 83 84 113 114 31 32 61 62 91 92 121 122 33 34 63 64 93 94 123 124

matlab reshape

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -