Be the first to rate this file! 129 downloads (last 30 days) File Size: 2.65 KB File ID: #25472

reshape2matrix.m v1.0 (Oct 2009)

by Carlos Adrian Vargas Aguilera

 

02 Oct 2009

Code covered by BSD License  

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

Download Now | Watch this File

File Information
Description

SYNTAX:
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);

DESCRIPTION:
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!

MATLAB release MATLAB 7.7 (R2008b)
Zip File Content  
Other Files license.txt,
reshape2matrix.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
reshape Carlos Adrian Vargas Aguilera 05 Oct 2009 11:06:42
size Carlos Adrian Vargas Aguilera 05 Oct 2009 11:06:43
ipermute Carlos Adrian Vargas Aguilera 05 Oct 2009 11:06:43
permute Carlos Adrian Vargas Aguilera 05 Oct 2009 11:06:43
matrix Carlos Adrian Vargas Aguilera 05 Oct 2009 11:06:43
first nonsingleton Carlos Adrian Vargas Aguilera 05 Oct 2009 11:06:43
dim Carlos Adrian Vargas Aguilera 05 Oct 2009 11:06:43
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com