Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
661 views
in Technique[技术] by (71.8m points)

plot - Plotting Implicit Algebraic equations in MATLAB

I wish to plot implicit functions in MATLAB. Like x^3 + xy + y^2 = 36 , equations which cannot be made into simple parametric form. Is there any simple method ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here are a couple of options...

Using ezplot (or fplot recommended in newer versions):

The easiest solution is to use the function ezplot:

ezplot('x.^3 + x.*y + y.^2 - 36', [-10 10 -10 10]);

Which gives you the following plot:

enter image description here


Using contour:

Another option is to generate a set of points where you will evaluate the function f(x,y) = x^3 + x*y + y^2 and then use the function contour to plot contour lines where f(x,y) is equal to 36:

[x, y] = meshgrid(-10:0.1:10);   % Create a mesh of x and y points
f = x.^3+x.*y+y.^2;              % Evaluate f at those points
contour(x, y, f, [36 36], 'b');  % Generate the contour plot
xlabel('x');                     % Add an x label
ylabel('y');                     % Add a y label
title('x^3 + x y + y^2 = 36');   % Add a title

The above will give you a plot nearly identical to the one generated by ezplot:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...