From: Monica Rainey on 26 Mar 2010 22:58 Hello, I'm trying to take the fourier transform of a shifted rect function. It appears that Matlab is connecting my samples in straight lines, and I want them smoothed out to be a curve. I know you can use the sinc function to do this, I'm just not sure how. Here's what I have so far: x = linspace (-5,5,5001); x =x(1:end-1); dx = x(2)-x(1); xi = linspace(0,1/dx,length(x)+1); xi = xi(1:end-1); n = 0:(length(xi)-1); %indices in the frequency domain k0 = x(1)/dx; %finds the offset index in the space domain C = exp(-1i*2*pi*k0*n/length(x)); %correction factor f = rect(x-3); F = fft(f)*dx; %corrected for phase using correction factor %Plot transform: fftplot(xi,F.*sinc(k*f), 'b'); %plot real part of function hold on fftplot(xi,imag(F).*sinc(k*f),'r'); %plot imaginary part of function hold off %Format plot set(gca,'xlim',[-5 5]) set(gca,'ylim',[-1 1]) title('Fourier transform of gaus(x)*sin(5*pi*x)') legend('Real','Imaginary'); xlabel('\xi[cycles/unit]') ylabel('F(\xi)') Thanks, Monica
|
Pages: 1 Prev: A problem with IFFT Next: want guidence for creating templates for english characters |