|
In article <gg3a9m$mko$1@fred.mathworks.com>, ida_haggstrom@yahoo.se
says...
> Hi!
> Something seem to have happened with my Matlab...
> I'm working with 4D images of size (128,128,63,32), and when I pick out a certain 2D slice of the image stack,e.g. image(:,:,30,30), and check the size of the result, I used to get the answer (128,128,1,1). That is, I still kept the singleton dimensions. Now however, if I do the same thing I only get a 128x128 size, with the singleton dimensions removed by themselves. I haven't applied squeeze or anything...
> The same thing happens if I do this:
>
> size(zeros(128,128,1,1)) = [128 128]
>
> when I switch the order though, it keeps singleton dimensions prior to multi-dimensions:
>
> size(zeros(1,128,128,1)) = [1 128 128]
>
> I want to keep the singleton dimensions, even if they are at the end of the matrix, and still pick out a 2D element from my 4D matrix. How can I do this? Thanks in advance! Cheers,
> Ida
>
Explicitly you can't do this in MATLAB. Implicitly, every array in
MATLAB has an iinfinite number of trailing dimensions that aren't shown,
each with length 1.
Perhaps functions like cat, permute, shiftdim can help...
--
Loren
http://blogs.mathworks.com/loren
|