MATLAB: I get error saying that z should be a matrix and not a scalar

multivariable

x = linspace (-1,1); y = linspace (-1,1); [X, Y] = meshgrid(x,y); Z=7*sin(pi.*x).*cos(3*pi.*x);
surf(X,Y,Z ) hold on contour(X,Y,Z) hold off
rotate3d on

Best Answer

Z=7*sin(pi.*X).*cos(3*pi.*X);