conform_dims(dims,x​,ndim)

Version 1.0.0.0 (942 Bytes) by Yuxin Jiang
Repmat a vector/matrix so that it conforms to the shape of the given dimension sizes.
39 Downloads
Updated 10 Jun 2017

View License

Repmat a vector/matrix so that it conforms to the shape of the given dimension sizes.
Similar with conform_dims in NCL http://www.ncl.ucar.edu/Document/Functions/Built-in/conform_dims.shtml
Usage:
output = conform_dims(dims,x,ndim)
dims: An array of dimension sizes of which x will be conformed to.
x: a vector/matrix whose dimensions must be a subset of dims.
ndim: An array of dimension indexes to indicate which dimension sizes
indicated by dims match the dimensions in x. The leftmost dimension index is 1.

Example:
h2d = rand(2,3);
h3d = rand(2,3,4);
y = [1;2;3];
y2d = conform_dims(size(h2d),y,2)
y3d = conform_dims(size(h3d),y,2)
y3d = conform_dims(size(h3d),y2d,[1 2])

Cite As

Yuxin Jiang (2024). conform_dims(dims,x,ndim) (https://www.mathworks.com/matlabcentral/fileexchange/63295-conform_dims-dims-x-ndim), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Large Files and Big Data 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.0.0.0