From: mb on 4 May 2010 04:11 I have a three dimentional matrix AxBxC and I want to remove (and hence make the matrix smaller) all elements that is zero in all three dimentions. How can I do this in an easy way? The matrix is to big to go in check elementwise if the element is zero and then remove it. /mb
From: Walter Roberson on 4 May 2010 04:30 mb wrote: > I have a three dimentional matrix AxBxC and I want to remove (and hence > make the matrix smaller) all elements that is zero in all three dimentions. What do you mean by an element being zero "in all three dimensions" ? > How can I do this in an easy way? > > The matrix is to big to go in check elementwise if the element is zero > and then remove it. Perhaps the following will help: ~any(M,3) would return a 2 dimensional logical matrix, A x B, with the value being set at (J,K) only if M(J,K,:) was all zero.
From: mb on 4 May 2010 04:40 Walter Roberson <roberson(a)hushmail.com> wrote in message <%WQDn.182230$NH1.158541(a)newsfe14.iad>... > mb wrote: > > I have a three dimentional matrix AxBxC and I want to remove (and hence > > make the matrix smaller) all elements that is zero in all three dimentions. > > What do you mean by an element being zero "in all three dimensions" ? > > > How can I do this in an easy way? > > > > The matrix is to big to go in check elementwise if the element is zero > > and then remove it. > > > Perhaps the following will help: > > ~any(M,3) > > would return a 2 dimensional logical matrix, A x B, with the value being > set at (J,K) only if M(J,K,:) was all zero. I'm not quite sure... I just want to remove the elements if it is zero in all three dimentions, the whole row or column doesn't need to be zeros. Also the resulting matrix should still be 3 dimentional. /Marit
From: Walter Roberson on 4 May 2010 04:44 mb wrote: > I just want to remove the elements if it is zero in all three > dimentions, the whole row or column doesn't need to be zeros. Also the > resulting matrix should still be 3 dimentional. I don't know what you mean by "if it is zero in all three dimensions" if you do not mean that the row or column (or page) has to be all zero. Could you give a small example, showing the exact input and output expected?
|
Pages: 1 Prev: Undefined function or variable Next: Diadem DAT files import to Matlab |