[scilab-Users] Atan function
Antoine Monmayrant
antoine.monmayrant at laas.fr
Tue May 10 15:26:51 CEST 2011
Le 10/05/2011 15:20, Adrien Vogt-Schilb a écrit :
> it looks like a bug, which could be linked to the fact that even if
> Xr(11:12)==[0 0], Xr(11:12) are complex number for scilab (try isreal(Xr(11:12))).
>
> are you trying to get the phase of thoses complex numbers?
> if yes, i suggest you to use something like imag(log(Xr(11:12)+%eps)) as a crapy
> workaround (instead of atan(imag(xr),real(xr)))
>
>
>
> Le 10/05/2011 14:38, Laurent Berger a écrit :
> > In this program
> >
> > clear;
> > N=256;
> > n=0:N-1;
> > Xr=zeros(1,N);
> > f0=2;
> > Xr(f0+1)=1/(2*%i);
> > Xr(N-(f0+1)+2)=-1/(2*%i);
> > Xr=Xr.*exp(%i*%pi*2*6*n/N);
> > xr=ifft(Xr);
> > disp (atan(imag(Xr(11:12)),real(Xr(11:12))))
> > disp (Xr(11)-Xr(12))
> >
> > results are
> > 0. 3.1415927
> >
> > 0
> >
> >
> > I don't understand why two numbers with a difference of 0 can have a numerical
> > phase of 0 or pi .
> > In matlab results are
> > 0 0
> > 0
> >
> >
> > !Scilab Version: 5.3.1.1299160056 !
> > ! !
> > !Operating System: Windows XP 5.1 !
> > ! !
> > !Java version : 1.6.0_18 !
> > ! !
> > !Java runtime information : Java(TM) SE Runtime Environment (build
> > 1.6.0_18-b07) !
> > ! !
> > !Java vm information : Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode) !
> > ! !
> > !Vendor specification: Sun Microsystems Inc. !
>
>
> --
>
> *Adrien Vogt-Schilb*
>
> Research Fellow
>
> vogt at centre-cired.fr<mailto:vogt at centre-cired.fr>
>
> Tel: (+33) 1 43 94 73 96
>
> Fax: (+33) 1 43 94 73 70
>
> CIRED
>
>
>
> 45 bis, Av de la Belle Gabrielle
>
> F-94736 Nogent-sur-Marne
>
> http://www.centre-cired.fr/
>
Definitely a bug that I encountered last year: a complex number with an
imaginary part that is strictly 0 is not real (or at least not always).
I ended up with a couple of thisnumberisreal=real(thisnumberisreal)
inside my code as a workaround.
It took me some time to understand what was going on.
Antoine
More information about the users
mailing list