[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Removing rows/columns from a matrix
From: |
Søren Hauberg |
Subject: |
Removing rows/columns from a matrix |
Date: |
Fri, 21 Mar 2008 15:50:08 +0100 |
Hi,
Let's say I have a 3D array 'A', and a binary 3-vector 'b':
A = rand(5,5,5);
b = [1, 0, 1];
I want to remove the first entry of 'A' in dimensions where 'b' is 1. In
the above example, I want
result = A(2:end, 1:end, 2:end);
This can be computed as (for arbitrary 'b')
b += 1;
result = A( b(1):end, b(2):end, b(3):end );
But how can I do something similar if 'A' is N-dimensional? I can't
think of any way of doing that.
Søren
- Removing rows/columns from a matrix,
Søren Hauberg <=