MATLAB Answers


Defining a domain over a period 2Pi and More

Asked by Balachandra on 14 Nov 2013
Latest activity Edited by Balachandra on 14 Nov 2013

When defining a sine wave in matlab, do we choose a domain [1:N]/N or [0:N-1]/N; These two domains differ by a grid point. However, stuff gets complicated when we take FFT. If I define

    N = 128;
    x = [0:N-1]/N;
    f = sin(2*pi*x);
    F = fftshift(fft(f));
    F(end+1) = 0;
    F = flipdim(F,2);
    F = F(1:end-1);
    f_inv = -real(ifft(ifftshift(F)));
    hold on

2) However, if I defined

x = [1:N]/N; 

and do the rest same, I get a sine wave in the final which is offset by 2 bins. Why so? and Which is correct?


Log in to comment.

0 Answers

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!