help-octave
[Top][All Lists]
Advanced

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

Re: function applied to each component in an if clause


From: Thomas Weber
Subject: Re: function applied to each component in an if clause
Date: Wed, 12 Mar 2008 07:27:50 +0100
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

On 11/03/08 02:54 -0700, sururi wrote:
> 
> I'm wondering if there is a practical way of applying a comparison operator
> to each component of a vector..

Use indices:

x = [0.5, 1, 2]
lower = (x < 2)
x(lower) = 4*x(lower)

In case someone else reads this: the last line above prints out all
(three) elements of 'x'. I expected only the two matching elements of x.
Is my expectation wrong?

        Thomas


reply via email to

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