[Scilab-users] shift phase in fft

paul.carrico at free.fr paul.carrico at free.fr
Thu Sep 29 13:46:42 CEST 2016


Thanks Rafael (and Antoine as well) 

Now I think I understand what went wrong 

Paul 
----- Mail original -----

De: "Rafael Guerra" <jrafaelbguerra at hotmail.com> 
À: "Users mailing list for Scilab" <users at lists.scilab.org> 
Envoyé: Jeudi 29 Septembre 2016 13:38:09 
Objet: Re: [Scilab-users] shift phase in fft 



Hi Paul, 

Your phase rotation seems to be working fine but the fft output is complex and only the real part is plotted by Scilab and that is why the resulting amplitude seems to be smaller. 

If you want to have your output real, one way is may be to handle separately the positive and negative frequencies as follows: 
clf () ; f = 10 ; // frequency omega = 2 * %pi * f; // circular frequency nb_T = 5 ; // number of periods t1 = 0 ; t2 = ( nb_T / f ) ; n = 10 ; t = linspace ( t1,t2, 2 ^ n ) ' ; // must be a power of 2 nl = size ( t, "*" ) ; s1 = 2 * sin ( omega * t ) ; // original signal plot ( t,s1, "r" ) ; phi = %pi / 3 ; s2 = 2 * sin ( omega * t + phi ) ; // targetted signal to be rebuilt plot ( t,s2, "b" ) ; // shift phase in the fft s1_fft = fft ( s1 ) ; s1_fft ( 1 : nl / 2 ) = s1_fft ( 1 : nl / 2 ) .* exp ( % i * phi ) ; s1_fft ( nl / 2 :$ ) = s1_fft ( nl / 2 :$ ) .* exp ( - % i * phi ) ; s1_new = ifft ( s1_fft ) ; plot ( t,s1_new, "--g" ) ; 


Regards, 
Rafael 





_______________________________________________ 
users mailing list 
users at lists.scilab.org 
http://lists.scilab.org/mailman/listinfo/users 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160929/f3f3f6d8/attachment.htm>


More information about the users mailing list