Ideal Low Pass Filter Concept in MATLAB
meshgrid is simply a way to create a discrete grid. If you think of a regular MATLAB matrix of size MxN, it defines indices from 1 to N in x and from 1 to M in y, with the step size of 1. But let's say you want to evaluate some function f(x,y) on the x-interval [-3, 1] and the y-interval [-1, 2], and you want your step size to be .2.  The meshgrid helps you create a matrix of all the x-values and a matrix of all the y-values.  If you do

[X,Y] = meshgrid(-3:0.2:1, -1:0.2:2);


You can then easily evaluate your function f(x,y).  For example f(X(1),Y(1)) = f(-3, -1). Of if f is a vectorized MATLAB function, you should be able to evaluate it on your entire grid with one line:

Z = f(X(:), Y(:));


In this particular example, the meshgrids contain the indices of the frequency coefficients in the same order used by fft2 function. Remember, the Fourier transform of an image is periodic, it wraps around. For calculations it is convenient to have the zero frequency at (0,0), then the positive frequencies, and then the negative 
frequencies wrapping around.

On the other hand, for visualization it is convenient to have the zero frequency in the center.  This is what the fftshift function does.  It is used purely for visualization.