Does anyone know how to add singleton dimensions to an array?
I currently have a matrix A that is size 1010025x1. I would like to add a 3rd dimension to this so that it's 1010025x1x1. I've tried permute(A, [1 2 3]) however this doesn't work giving me the dimensions I had at the start again ( 1010025x1)...
Cheers!
Matt
....AddDimension adds the dimension to the data on disc. Most MATLAB functions including LOAD, WHOS etc strip away any trailing singleton dimensions so the effects of AddDimension will not show until the final dimension is >=2.
MATLAB implicitly has an infinite number of trailing singleton dimensions
after the non-singleton array dimensions. If you are trying to fill in the
3rd dimension, you can just do something like this:
A(2:3,1,4) = 17;
The array will then be 1010025x1x4 and values not specified will be filled
with 0. Unless your array is sparse, in which case, they are only 2-d.
--
Loren
http://blogs.mathworks.com/loren/
http://matlabwiki.mathworks.com/MATLAB_FAQ