help-octave
[Top][All Lists]
Advanced

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

Re: function values vector


From: Francesco Potortì
Subject: Re: function values vector
Date: Mon, 17 May 2010 08:54:23 +0200

>I have a vector x=linspace(0,2*pi,256). There is a function H given as
>follows:
>
>function y=H(x)
>    if (x<pi)
>        y=0;
>    else 
>        y=1;
>    endif
>end
>
>Now, I want a vector Y such that each of its coordinates xi is H(xi). What's
>the best way to that? Y=H(X) doesn't work (it makes Y=1, which I don't
>understand).

Ah, and I don't know why you get 1, I would have expected an error.  In
fact, the 'if' condition is (x<pi), which is a bool matrix instead of a
single bool value.  I don't know why Octave does not give an error here,
and why it is evalued as false.

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa         Email: address@hidden
(entrance 20, 1st floor, room C71)     Web:   http://fly.isti.cnr.it/


reply via email to

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