The problem was, that, I was passing X and Y as matrices, which my_gabor_filter(..) cannot handle correctly, so instead I evaluated my_gabor_filter at each point (x,y) with x in X and y in Y, and so the modified version of my_gabor_filter is as follows :
NOTE : I also adjusted the range for X and Y so that the mesh-grid is clearly seen
function plot_gabor_filter()
mu = 0;
nu = 0;
sigma = 1;
[X,Y] = meshgrid(-2:0.1:2,-2:0.1:2);
Z = zeros(41,41);
for i = 1:1:41
for j = 1:1:41
Z(i,j) = imag(my_gabor_filter(X(i,j),Y(i,j),mu,nu,sigma));
end
end
surf(X,Y,Z,'EdgeColor','black')
xlabel('x axis');
ylabel('y axis');
zlabel('g(x,y)');
end
and, This solves my problem.