View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
reshape2matrix.m v1.0 (Oct 2009)

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 2.65 KB File ID: #25472 Version: 1.0
image thumbnail

reshape2matrix.m v1.0 (Oct 2009)



Reshapes a multidimensional array into a 2-D matrix with an specific dimension in the columns!

| Watch this File

File Information

a) N-dim array X to matrix Y:
>> Y = reshape2matrix(X,DIM);
b) Matrix Y to N-dim array X:
>> X = reshape2matrix(Y,DIM,SIZE);

Some MATLAB or users defined functions do not work through an specific dimension in a multidimensional array, whether because its not supported like in FILTFILT or the output is a matrix like in CORRCOEF.

A workaround on this problem is to specify the elements of X in the specific dimension we like to work (DIM) with some index. Another one is to transform this multidimensional array into a simple 2-dimensional matrix with the vectors of the DIM dimension as its columns.

This latter is exactly what this little program does. Besides, after working with the generated matrix, you can get the original multidimensional shape by calling once again this function with the third input SIZE of the original array.

Enjoy it!
Any comments and bug reports will be very appreciated!


This file inspired Dim Func.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us