[Scilab-users] shift phase in fft

Rafael Guerra jrafaelbguerra at hotmail.com
Thu Sep 29 13:38:09 CEST 2016


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


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


More information about the users mailing list