[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: permute doesn't delete singletons
From: |
Jonathan Stickel |
Subject: |
Re: permute doesn't delete singletons |
Date: |
Thu, 05 May 2005 09:56:36 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050317) |
You can use the squeeze command:
octave:14> x = zeros(10,1,2);
octave:15> z = permute(x,[3,1,2]);
octave:16> size(z)
ans =
2 10 1
octave:17> z = squeeze(permute(x,[3,1,2]));
octave:18> size(z)
ans =
2 10
I'm not sure if the maintainers are interested in modifying permute to
automatically "squeeze" the dimensions.
Jonathan
Tom Holroyd wrote:
Hi.
Trailing singleton dimensions are automatically removed, right? Like,
octave:67> x=zeros(10,3,1);
octave:68> size(x)
ans =
10 3
But if I do:
octave:75> x=zeros(10,1,2);
octave:76> z=permute(x,[3,1,2]);
octave:77> size(z)
ans =
2 10 1
I get a result with a trailing singleton dimension. I'm porting some
MATLAB code that expects the result of permute above to be size 2 10,
which it is under MATLAB. Can permute be changed to remove the
singleton dimension?
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------