[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Removing rows/columns from a matrix
From: |
John W. Eaton |
Subject: |
Re: Removing rows/columns from a matrix |
Date: |
Fri, 21 Mar 2008 11:43:37 -0400 |
On 21-Mar-2008, Søren Hauberg wrote:
|
| fre, 21 03 2008 kl. 08:15 -0700, skrev Ben Abbott:
| > This will work in Octave (does not work in Matlab).
| >
| > A = rand (5, 5, 5);
| > b = {2:5 1:5 2:5};
| > A = A(b{:});
| >
| > The only trick is creating the cell for b.
| Matlab doesn't matter, so I've the following:
|
| idx = cell(1, ndims(A));
| for k = 1:ndims(A)
| idx{k} = (b(k)+1):size(A,k);
| endfor
| A = A(idx{:});
|
| which seems to work.
Other than the endfor, I think this should also work in Matlab.
jwe