spectral interpolation of the function in matlab

6 views (last 30 days)
Hi,
I wonder if someone can give me example of spectral interpolation of the function.
funtioncs: fft, fftshift, or any other

Answers (1)

Wayne King
Wayne King on 6 Dec 2011
Hi Feruz, just pad the fft(), that interpolates the DFT.
Fs = 1024;
t = 0:1/Fs:(1000*(1/1024))-(1/1024);
x = cos(2*pi*100*t)+randn(size(t));
xdft = fft(x);
plot(abs(xdft));
% now pad to 1024 to interpolate at 1 Hz spacing
xdft1 = fft(x,1024);
figure;
plot(abs(xdft1));
Look how much narrower the line component shows up in the latter
  2 Comments
Feruz
Feruz on 6 Dec 2011
Hi Wayne,
This is my code:
m = 4;
N = 2^m;
L = N;
M = 10;
j = 0:N-1;
x = j*L/N;
f = exp(-M*(j/L-0.3).^2);
z = fft(f,400);
figure;
plot(abs(z));
%z = fftshift(z);
figure;
plot(f);
But look at the plot, shouldn't be my interpolation close to the function?
Greg Heath
Greg Heath on 12 Dec 2011
f is a bad choice for. a function. Use it for frequency.
f is complex. Either make it real or plot ampliitude and phase
Do not plot vs index. Plot f vs time and z vs frequency
Hope this helps.
Greg

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!