[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: indices of zeros in matrix
From: |
Geraint Paul Bevan |
Subject: |
Re: indices of zeros in matrix |
Date: |
Thu, 10 Jul 2003 10:00:55 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
bertrand roessli wrote:
| Hello,
|
| does anybody know if there is a function which returns
| the indices of all zero elements in a matrix?
|
| thank you
|
Bertrand,
you can use the "find" function:
octave:1> a = [ 1 , 0 , 3 ; 0 , 5 , 6 ; 0 , 0 , 9 ]
a =
~ 1 0 3
~ 0 5 6
~ 0 0 9
octave:2> find ( a == 0 )
ans =
~ 2
~ 3
~ 4
~ 6
Note that fortran-style indices are given.
- --
Geraint Bevan
Department of Mechanical Engineering
University of Glasgow
Tel: +44 (0)141 330 5917
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/DX+XcXV3N50QmNMRAtqvAJ9P9sGM9gW0r8cmnYSwx2qfFAHHyQCfeev1
6TFoz2qWiKQX9wOHo/gdSF4=
=smTy
-----END PGP SIGNATURE-----
-------------------------------------------------------------
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
-------------------------------------------------------------