Defining a domain over a period 2Pi and More

3 views (last 30 days)
Balachandra
Balachandra on 14 Nov 2013
Edited: 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)));
norm(f-f_inv,'fro');
plot(f,'b*');
hold on
plot(f_inv,'r*');
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?

Answers (0)

Categories

Find more on Special Functions in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!