本文介绍了在 MATLAB 中绘制隐式代数方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在 MATLAB 中绘制隐式函数.像 x^3 + xy + y^2 = 36 一样,方程不能变成简单的参数形式.有什么简单的方法吗?
解决方案
这里有几个选项...
使用
使用
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 ?
解决方案
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:
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
:
这篇关于在 MATLAB 中绘制隐式代数方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!