登录论坛

查看完整版本 : 在MATLAB中绘制隐式代数方程


poster
2019-12-10, 20:41
我希望在MATLAB中绘制隐式函数。像x ^ 3 + xy + y ^ 2 = 36一样,不能将方程变成简单的参数形式。有没有简单的方法?



回答:

这里有几个选择...

使用ezplot (https://www.mathworks.com/help/matlab/ref/ezplot.html) (或在较新版本中建议使用fplot (https://www.mathworks.com/help/matlab/ref/fplot.html) ):

最简单的解决方案是使用ezplot (https://www.mathworks.com/help/matlab/ref/ezplot.html)函数:

ezplot('x.^3 + x.*y + y.^2 - 36', [-10 10 -10 10]); 这给你下面的情节:

https://i.stack.imgur.com/o9gj8.jpg (https://i.stack.imgur.com/o9gj8.jpg)




使用contour (https://www.mathworks.com/help/matlab/ref/contour.html) :

另一种选择是生成一组点,您将在其中评估函数f(x,y) = x^3 + x*y + y^2 ,然后使用函数contour (https://www.mathworks.com/help/matlab/ref/contour.html)绘制其中f(x,y)轮廓线等于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 ay label title('x^3 + xy + y^2 = 36'); % Add a title 上面给出的绘图几乎与ezplot (https://www.mathworks.com/help/matlab/ref/ezplot.html)生成的绘图相同:

https://i.stack.imgur.com/oMwtq.jpg (https://i.stack.imgur.com/oMwtq.jpg)



更多&回答... (https://stackoverflow.com/questions/2722500)