No BSD License  

Highlights from
catdim

Be the first to rate this file! 1 Download (last 30 days) File Size: 2.02 KB File ID: #15990

catdim

by Andreas Hoechner

 

20 Aug 2007 (Updated 20 Aug 2007)

Unconcatenate array and catenate along other dimension.

| Watch this File

File Information
Description

OUT=CATDIM(DIMS,A)
with DIMS=[da1,da2;db1,db2;..] an array of size [n,2].
Unconcatenates array A along dimension da1 and concatenates along da2,
then db1 and so on.
At the end squeezes result to remove singelton dimensions.
Useful to reshape a multidimensional array to display it e.g. with imagesc.

Examples:

a=[1,2,3;4,5,6]; a=cat(3,a,a+10)
a(:,:,1) =
     1 2 3
     4 5 6
a(:,:,2) =
    11 12 13
    14 15 16

catdim([3,1],a)
ans =
     1 2 3
     4 5 6
    11 12 13
    14 15 16
catdim([3,2],a)
ans =
     1 2 3 11 12 13
     4 5 6 14 15 16

b=[1,2;,3,4]
b =
     1 2
     3 4
catdim([1,2],b)
ans =
     1 2 3 4

c=cat(4,a,a+20)
c(:,:,1,1) =
     1 2 3
     4 5 6
c(:,:,2,1) =
    11 12 13
    14 15 16
c(:,:,1,2) =
    21 22 23
    24 25 26
c(:,:,2,2) =
    31 32 33
    34 35 36

catdim([3,2;4,1],c)
ans =
     1 2 3 11 12 13
     4 5 6 14 15 16
    21 22 23 31 32 33

Acknowledgements
This submission has inspired the following:
reshapec: a pedestrian col-row reshaper
MATLAB release MATLAB 7.3 (R2006b)
Other requirements Please inform author of bugs.
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
matrices Andreas Hoechner 22 Oct 2008 09:23:35
concatenate Cristina McIntire 23 Feb 2009 15:13:37
cat Cristina McIntire 23 Feb 2009 15:13:37
reshape Cristina McIntire 23 Feb 2009 15:13:37
uncat Cristina McIntire 23 Feb 2009 15:13:37

Contact us at files@mathworks.com