[Top][All Lists]

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

Re: Puncher soft limiter !!!

From: Lorenzo Fiorentini
Subject: Re: Puncher soft limiter !!!
Date: Wed, 04 Jun 2003 13:24:48 +0200
User-agent: Opera7.11/Win32 M2 build 2880

If you first check the argument passed, you will find theta the pbm is not in your function, but in the way Octave (and matlab) computes the last element of your [a:step:b] argument to the function.

Not always the last element of your vector [a:(b-a)/n:b] is b. Sometimes it is b-(b-a)/n, because of rounding done n times when adding (b-a)/n. NB. If the step is not a power of two [2^(-k)], there must be some rounding on a binary machine.

Try adding eps or 2*eps or step/10 to b, or use a different sintax like (a+[0:n]*(b-a)/n).

I am (pretty ;) sure it will work.


On Wed, 4 Jun 2003 01:57:10 +0100 (BST), cctsim <address@hidden> wrote:

Hi all,

I have written the c++ code below to implement a
puncher funtion for a soft limiter. By definition, that is

f(x)=x for -A<=x<=A and f(x)=0 otherwise

I thought it was working fine until I noticed
the following problem:

ans = 5
ans = 5

which are ok, but
ans = 4.9000 which is wrong !!


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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