[ img ] = drawImplicitFun( f,xRange,yRange,grid )
This is simple program to plot a implicit function F on IMG
F is a function handle with two variables
IMG is a binary image containing the plot of F=0.
f = @(x,y)cos(x)+cos(y)-cos(x.*y);
img = drawImplicitFun(f,[-10,10],[-10,10],0.05);
1. The program makes use of the fact that if function f is continuous in [a,b] and f(a)*f(b)<=0, then there exists a point p between [a,b] s.t. f(p)=0. So if there are singularity points, the plot may be wrong. If the zero point is not on the grid, this program may not show all the zero points, e.g. when the function value changes too fast, or the zero point is also a minimum point. But in most cases, this program is OK.
2. Sometimes the image shown by imshow containa unexpected dash lines (which should have been continuous). This may be caused by interpolation methods of imshow. Try to zoom the image.
3. If you want a plot of several implicit functions, just use the OR operator on several images.
Ke Yan (2021). plot 2D implicit function (https://www.mathworks.com/matlabcentral/fileexchange/44260-plot-2d-implicit-function), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!