permuteMerge(x, dims)
When manipulating multidimensional matrices, there might be situations that requires swapping (permute) and merging dimensions (reshape). This function simplifies the code and performs the swapping and merging in one function call.
y = permuteMerge(x, dims);
x: input matrix
dims: Cell array indicating how dimensions are to be permuted and merged. Each cell defines an output matrix dimension in the order that is supplied. Specify multiple elements in a cell to merge specific input matrix dimensions.
e.g. permuteMerge(x, {[4 3],[1 2]})
- Rearrange 4D matrix dimensions in the order [4 3 1 2] (@permute)
- Merge dimensions [4 3] and [1 2] to form a 2D output matrix.
Cite As
Spencer Chen (2026). permuteMerge(x, dims) (https://www.mathworks.com/matlabcentral/fileexchange/48415-permutemerge-x-dims), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
