contours of an implicit function f(x,y,z)=0 in MATLAB

I've already known how to plot a 3d implicit function f(x,y,z)=0 by using the isosurface function. Now I'm curious about how to draw contours of it. Like this one:

f(x,y,z) = sin((x.*z-0.5).^2+2*x.*y.^2-0.1*z) - z.*exp((x-0.5-exp(z-y)).^2+y.^2-0.2*z+3)


You could numerically run over Z and look for when the sign changes, creating a matrix that holds the Z value, it's not elegant, but it works.

%Create function to evaluate
eq=eval(['@(x,y,z)',vectorize('sin((x*z-0.5)^2+2*x*y^2-0.1*z) - z*exp((x-0.5-exp(z-y))^2+y^2-0.2*z+3)'),';'])

%Create grid of x and y values

%Create dummy to hold the zero transitions

%Run over Z and hold the values where the sign changes
for i=0:0.001:0.04

%Contour those values

Edit: I found a slightly more elegant solution using the function scatteredInterpolant

%Create function to evaluate
eq=eval(['@(x,y,z)',vectorize('sin((x*z-0.5)^2+2*x*y^2-0.1*z) - z*exp((x-0.5-exp(z-y))^2+y^2-0.2*z+3)'),';']);

%Create grid to evaluate volume

$Find the isosurface
s=isosurface(xm,ym,zm,eq(xm,ym,zm), 0);

$Use the vertices of the surface to create a interpolated function

%Create a grid to plot

%Contour this function
contour(x,y, F(x,y),30)

Need Your Help

CURL working, JSON not working

php jquery json curl

I have a Json get request that works perfectly when I use CURL to send it over php , but when I try to do the same thing with getJSON (which is the requirement), all I get back is status is error w...

Display Image from mysql database to fpdf

php pdf fpdf

I am new to fpdf. i can fetch required data from database and generate the pdf. but i would like to fetch the images from database and display that in the generated pdf. i have stored my images int...