[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Zero entries in one column of a matrix
From: |
Miquel Cabanas |
Subject: |
Re: Zero entries in one column of a matrix |
Date: |
Thu, 01 Apr 2004 09:54:33 +0200 |
User-agent: |
Mutt/1.3.28i |
hello,
On Wed, Mar 31, 2004 at 10:40:05AM -0800, Henry F. Mollet wrote:
>
> But how does the elimination of the zero entries (in the second
> column of M) work in M (statement, 1) producing col vector of
> length 100-25=75, and M (same statement, 2) producing col vector
> of length 75 also?
because *statement* (i.e. "M(:,2) ~= 0" in your example) produces
a boolean matrix, which is regarded as a matrix of indexes and
handled by octave differently than standard matrices or vectors.
octave:1> M = [ 1 1; 2 0; 3 1; 4 1; 5 0; 6 1; 7 1; 8 1; 9 0]
octave:2> M_boolean = M(:,2) ~= 0;
octave:3> whos
*** local user variables:
prot type rows cols name
==== ==== ==== ==== ====
rwd matrix 9 2 M
rwd bool matrix 9 1 M_boolean
note though that as soon as you convert your bool-matrix into a
plain-matrix this feature is gone,
octave:4> M_plain = M_boolean .+ 0;
octave:5> whos
*** local user variables:
prot type rows cols name
==== ==== ==== ==== ====
rwd matrix 9 2 M
rwd bool matrix 9 1 M_boolean
rwd matrix 9 1 M_plain
octave:6> M( M_plain , 1);
error: invalid row index = 0
Miquel
--
Miquel E Cabanas ------------------------------------------------------
SeRMN, Universitat Autonoma de Barcelona (address@hidden)
------------------------------------------o-oo--ooo---ooo--oo-o--------
-------------------------------------------------------------
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
-------------------------------------------------------------
- Re: Zero entries in one column of a matrix,
Miquel Cabanas <=