function implplot(funct,xyrange,fns) % % Implicit Plot of a function % % function implplot(funct,xyrange,fns) % % funct is an 'inline' function f(x,y)=0. % % xyrange = [xmin,xmax,ymin,ymax] range over which x and y is plotted. % (Default(-5,5), (-5,5)) % % fns is the number of grid points used to calculate the plot. % (Default fns=500) % % Example: % To plot x^2+y^2=4 write function f as an 'inline' function of x and y. % % f=inline('x^2+y^2-4','x','y') % implplot(f,[-3 3 -3 3]) % %On the resulting graph, the standard x-axis (y-axis) corresponds to x (y). if nargin == 1; xyrange=[-5,5,-5,5]; fns=200; end if nargin == 2; fns=200; end xm=linspace(xyrange(1),xyrange(2),fns); ym=linspace(xyrange(3),xyrange(4),fns); [x,y]=meshgrid(xm,ym); fvector=vectorize(funct); fvalues=feval(fvector,x,y); contour(x,y,fvalues,[0,0],'b-');