[scilab-Users] Atan function

Adrien Vogt-Schilb vogt at centre-cired.fr
Tue May 10 15:20:56 CEST 2011


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/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110510/dac3b5a6/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logocired.png
Type: image/png
Size: 4092 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20110510/dac3b5a6/attachment.png>


More information about the users mailing list