Home » News & Blogs » Hooray, Octave supports numpy-style boolean array indexing operations
Bookmark and Share
Exploding Galaxies and other Catastrophysics

Hooray, Octave supports numpy-style boolean array indexing operations

16 Oct 2014, 11:52 UTC
Hooray, Octave supports numpy-style boolean array indexing operations
(200 words excerpt, click title or image to see full post)

I've only just discovered that Gnu Octave (the Gnu version of Matlab) supports numpy-style boolean array indexing operations, in particularlogical operations on vectors to return boolean true/false vectorsarray indexing using vectors on vectorsAn example, using a simple vector a.octave:2> a=[1 2 3 4 1 2 3 4]a = 1 2 3 4 1 2 3 4Create a boolean mask called b with all elements of a greater than 2. octave:3> b=a > 2b = 0 0 1 1 0 0 1 1Now use b to access only those elements of a that are true in the mask array b. octave:4> a(b)ans = 3 4 3 4Why use Octave when we have python/numpy/scipy? Sometimes its just faster to fire up octave to get a look at data, and matlab/octave syntax is much less verbose than python.

Latest Vodcast

Latest Podcast

Advertise PTTU

NASA Picture of the Day

Astronomy Picture of the Day

astronomy_pod