MATLAB: “Contour not rendered for non-finite ZData” warning, working fine on Mathematica

3d plots

Hello,
I am trying to exectute this script:
[x,y] = meshgrid(-5:0.25:5);
z = (x.^2 + y.^4)/sqrt(4.*x.^2 + 4.*y.^2);
contour3(z)
It's working just fine in wolfram mathematica:
h := (x^2 + y^4)/Sqrt[4*x^2 + 4*y^2]
Plot3D[g, {x, -5, 5}, {y, -5, 5}]
How can I get it to work?

Best Answer

[x,y] = meshgrid(-5:0.25:5);
z = (x.^2 + y.^4)./sqrt(4.*x.^2 + 4.*y.^2);
contour3(x,y,z)
YOu forgot to put ./ (element by element division) between numerator and denominator.