[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Filtering
From: |
Hall, Benjamin |
Subject: |
RE: Filtering |
Date: |
Mon, 28 Feb 2005 09:21:23 -0500 |
Try:
x( logical(ans2) )
to tell Octave that ans2 is to be treated like an index vector -- which is
*basically* the same as Laurent's suggestion of
x( ans2==1 )
-----Original Message-----
From: Hamish Allan [mailto:address@hidden
Sent: Monday, February 28, 2005 8:24 AM
To: address@hidden
Subject: Filtering
Hi,
It seems that matrices returned by comparison operators are 'special',
for example:
octave:1> x = [1 2 3 4 5]
x =
1 2 3 4 5
octave:2> x > 1
ans =
0 1 1 1 1
octave:3> x(ans)
ans =
2 3 4 5
octave:4> ans2 = [0 1 1 1 1]
ans2 =
0 1 1 1 1
octave:5> x(ans2)
error: invalid vector index = 0
octave:5>
Why is this? How else might I achieve what I want to do, which is:
octave:5> x((x > 1) .* (x < 4))
ans =
2 3
octave:6>
Many thanks,
Hamish
-------------------------------------------------------------
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
-------------------------------------------------------------
- Filtering, Hamish Allan, 2005/02/28
- RE: Filtering,
Hall, Benjamin <=