[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Integration with quad
From: |
Allen.Windhorn |
Subject: |
RE: Integration with quad |
Date: |
Thu, 10 Dec 2009 10:05:02 -0600 |
-----Original Message-----
From: Jaroslav Hajek [mailto:address@hidden
>> You can also write:
>>
>> function y = rect(t)
>> y = (t<=0.5);
>> endfunction
>>
>> This function will work on a vector.
> Beware of this, though. The above produces a *logical* result,
> not a numeric one. In most contexts logicals are auto-converted
> to reals (e.g. when used in arithmetics) but there may be some
> cases where this might make a difference. It's bit safer is to
> ensure the conversion yourself:
> y = double (t <= 0.5);
Maybe more elegant:
y = sign(1-sign(t-0.5))
Should look up the sign function, but I suppose it is C code.
This is helping me, as I am working on piecewise-linear
representations of functions.
Regards,
Allen
Re: Integration with quad, Przemek Klosowski, 2009/12/09