MATLAB: Error when Plotting sin(x)*sin(y) mesh… Please point me in the right direction. ‘Error: Unbalanced or unexpected parenthesis or bracket.’

mesh plotssin(x)sin(y)

x = -2:0.01:2;
y = -3:0.01:3;
[X,Y] = meshgrid(x,y);
Z = sin(pi*X.)*sin(pi*Y)/(pi^2*X.*Y);
mesh(x,y,Z)
Attempting to plot this surface. I am coming across an 'Error: Unbalanced or unexpected parenthesis or bracket.' error that I have narrowed down to the sin x * sin y part of the function. Even when I simplify it to >>sin(X.)*sin(Y); (as well as many other slightly different forms of that) I get the same error. I count even parenthesis… Any suggestions?
Thanks.

Best Answer

Instead of
Z = sin(pi*X.)*sin(pi*Y)/(pi^2*X.*Y);
try
Z = sin(pi*X).*sin(pi*Y)./(pi^2*X.*Y);