|
From: | Quentin Spencer |
Subject: | Re: Easy about Matrices |
Date: | Mon, 18 Apr 2005 13:20:06 -0500 |
User-agent: | Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) |
Frank Palazzolo wrote:
This syntax works as well: x = randn(1,1000); x_positive = (x>=0); x_negative = (x<0); I'm not sure if it's any more efficient, but it seems it would be, since it never needs to build an explicit index vector. -Frank
This is definitely faster, but it doesn't return the same matrix: octave:1> x=randn(1,10); octave:1> (x>0) ans = Columns 1 through 8: 1 1 0 0 0 0 1 0 Columns 9 and 10: 1 1 octave:3> x(find(x>0)) ans = 0.93970 0.38451 0.30387 0.81479 2.46831 ------------------------------------------------------------- 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 -------------------------------------------------------------
[Prev in Thread] | Current Thread | [Next in Thread] |