MATLAB: Tring to plot the 3d and contour levels of a function

3d surfacecontourfunction

the function is z(x,y) = cos(2y-x)sin(2x)
with the range of x and y values mentioned in the code.
my code:
clc
clear
function [z]= contour(x,y)
x=[-pi:0.1:pi./2]
y=[-pi:0.1:pi]
z = cos(2y-x).*sin(2x)
end
[xx,yy]=meshgrid(x,y)
zz = cos(2y-x).*sin(2x)
figure
surf(xx,yy,zz)
xlabel('X')
ylabel('Y')
zlable('Z')
shading interp
colorbar
when i run it in the command window it says:
Error: File: contour.m Line: 6 Column: 10
Invalid expression. Check for missing multiplication operator, missing or
unbalanced delimiters, or other syntax error. To construct matrices, use
brackets instead of parentheses.
-this refers to this line of code:
z = cos(2y-x).*sin(2x)

Best Answer

clc
clear
x=-pi:0.1:pi/2
y=-pi:0.1:pi;
[xx,yy]=meshgrid(x,y)
zz = cos(2*yy-x).*sin(2*xx);
% ^------------^------ missed it
figure
surf(xx,yy,zz)
xlabel('X')
ylabel('Y')
zlabel('Z')
shading interp
colorbar