MATLAB: Singleton dimention as last dimension in matrix

singleton dimension

Hello,
How do I create a singleton dimension as a last dimension in matlab, for example, so that size = 64 64 1.
I've tried reshape(x,[64 64 1]), but the resultant matrix is 64×64, not 64x64x1. Similarly with permute.
Thanks for any help!

Best Answer

Arrays in MATLAB have an implied infinitely long series of trailing singleton dimensions. You can index into them with no problem. For example
>> x = rand(3,3);
>> x(2,3,1,1,1,1,1,1,1,1,1,1,1)
is a valid indexing into x.
What is it that you are trying to do, that you need to emphasize that the array is 64x64x1?