help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Index expressions, boolean types and numerical types


From: Heber Farnsworth
Subject: Re: Index expressions, boolean types and numerical types
Date: Fri, 24 Oct 2003 16:47:46 -0500

That's because k=y<11 is a boolean. When you type y(k) it returns the corresponding element of y if k is "true" for that element. But y(ones(1,10)) returns a vector of size 10x1 all of whose elements are the 1st element of y.

Heber

On Friday, October 24, 2003, at 03:30 PM, Greg Novak wrote:

Does Octave have boolean types? Does it keep track of them silently? How do you do casts between numerical types and boolean types? If there are no boolean types, then how does the following fragment of a session make
sense?

octave:68> y=1:10
y = 1   2   3   4   5   6   7   8   9  10
octave:69> y(y<11)
ans = 1   2   3   4   5   6   7   8   9  10
octave:70> k=y<11
k = 1  1  1  1  1  1  1  1  1  1
octave:71> y(k)
ans = 1   2   3   4   5   6   7   8   9  10
octave:72> k=ones(1,10)
k = 1  1  1  1  1  1  1  1  1  1
octave:73> y(k)
ans = 1  1  1  1  1  1  1  1  1  1
octave:74>

k looks exactly the same when I assign it by k=y<11 or k=ones(1,10), but
the behavior of y(k) is very different in the two cases.

What gives?
Thanks,
Greg



-------------------------------------------------------------
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
-------------------------------------------------------------




-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]