Reverse concatenation: separate a data array along a specified dimension.

Version 1.1.0.0 (1.62 KB) by DS
INVERSE_CAT splits a given data array into sub-arrays along the specified dimension.
447 Downloads
Updated 10 Apr 2012

View License

[A B]=INVERSE_CAT(DIM,C) splits array C along dimension, DIM, returning sub-arrays A and B.

Examples:
M = [1 2 3; 4 5 6; 7 8 9];
C = cat(2,M,M)
[A B] = inverse_cat(2,C) ... returns A=M and B=M
[A B] = inverse_cat(1,rot90(C)) ... returns A=rot90(M) B=rot90(M)
[A B] = inverse_cat(3,cat(3,M,M)) ... returns A=M and B=M

-----
Note: There are certainly more efficient ways to separate concatenated data. Suggestions for improvement are much appreciated.

*Thanks to Jan Simon for insightful comments.

Cite As

DS (2024). Reverse concatenation: separate a data array along a specified dimension. (https://www.mathworks.com/matlabcentral/fileexchange/36097-reverse-concatenation-separate-a-data-array-along-a-specified-dimension), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Creating and Concatenating Matrices in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.0

Added Jan Simon's method to handle dimensions > 3.

1.0.0.0