MATLAB: I keep getting this error “Error using contour (line 48) Z must be at least a 2×2 matrix. Error in Test2Prob1 (line 73) contour(X,Y,Z,6);” please what am i doing wrong

contourplot

x = linspace(-3,3);
y = linspace(-3.5,3.5);
[X,Y] = meshgrid(x,y);
Z = ((x.^2 – 1)+ (y.^2 -4) +(x.^2 -1).* (y.^2 -4))./((x.^2 + y.^2 + 1).^2) contour(X,Y,Z,6);

Best Answer

You create the grids but you calculate with the vectors. Change your Z to use X and Y