Hello, im a physics engineering student and i need a little help with fft function. I wrote the following code everything works, but when i get the fft. I was supose to obtain a sinc function and if you take a close look, it is a sinc, but in the wrong points, can anyone help me with this?(adsbygoogle = window.adsbygoogle || []).push({});

if you dont know/remember what a sinc function looks like:

https://www.google.pt/search?q=3d+s...%2Fwiki%2FFile%3AMatlab_surf_sinc.svg;561;420

x0=0;

y0=0;

dx=5;

dy=5;

px=0.05;

py=0.05;

dxx=1;

dyy=1;

n=dx/px+1;

m=dy/py+1;

xx=-dx/2:px:dx/2;

yy=-dy/2:py:dy/2;

[X,Y]=meshgrid(xx,yy);

Z=zeros(n,m);

%w=X.^2+Y.^2;

for i=1:n

for j=1:m

if X(i,j)>=x0-dxx/2 && X(i,j)<=x0+dxx/2 && Y(i,j)>=y0-dyy/2 && Y(i,j)<=y0+dyy/2

Z(i,j)=1;

end

end

end

A=fft(Z);

B=A.*conj(A);

figure(1)

surf(X,Y,Z)

colormap jet

colorbar

figure(2)

surf(X,Y,B)

colormap jet

colorbar

Also, how i make sure that Z, has always the size of the matrixs X and Y?

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Help with fft

Loading...

Similar Threads - Help | Date |
---|---|

Matlab MATLab: Not enough inputs for nlinfit | Nov 16, 2017 |

Matlab Help needed to fix a matlab code | Nov 8, 2017 |

LaTeX Help with page dimensions in latex | Nov 2, 2017 |

Matlab Octave integral computation help | Apr 20, 2017 |

Matlab 2D plotting error help please | Aug 28, 2016 |

**Physics Forums - The Fusion of Science and Community**