How to reshape a 16x16x16x16 matrix to 256x256 whilst maintaining consistency

1 view (last 30 days)
Hi
I have a pixel grid (16,16) and I've generated a matrix A whose (i,j,k,l)th element specifies a property of the pairing of the pixel (i,j) with the pixel (k,l), for i,j,k,l = 1,...16.
Now let's say I have a separate 16-by-16 matrix "a" which I reshape to "b" such that "b = reshape(a,256,1)". I want to reshape A into a 256x256 matrix B according to this same rule, so that A(i,j,k,l) = B(m,n), where a(i,j) = b(m) and a(k,l) = b(n).
In other words, I need to reduce to a single dimension the 1,2 dimensions of A, and simultaneously the 3,4 dimensions, so that the new matrix B is consistent with all my other matrices which are consistent with the b = reshape(a,256,1) rule.
I'm far too confused to work out if this is achieved by a simple "reshape(A,256,256)", and I need to be certain before proceeding. Thanks for _any _help.
Mike

Accepted Answer

Matt J
Matt J on 13 Nov 2012
Edited: Matt J on 13 Nov 2012
Yes, it's the same. But you can easily convince yourself using a few simple tests.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!