How to plot cubic equations ?

27 次查看(过去 30 天)
Hello all,
I'm new to matlab and am stuck trying to plot the function x*y*(x^2+y^2)>=47.3.
can someone explain/show how both the equality and inequality can be plotted.
Thanks.

采纳的回答

Star Strider
Star Strider 2021-3-3
Here is one approach:
f = @(x,y) x.*y.*(x.^2+y.^2) - 47.3;
figure
fih = fimplicit(f, [-10 10 -10 10]);
xv = fih.XData;
yv = fih.YData;
v0 = ones(size(xv));
Lpos = xv>=0;
xpos = xv(Lpos);
ypos = yv(Lpos);
xneg = xv(~Lpos);
yneg = yv(~Lpos);
xneg = xneg(~isnan(xneg));
yneg = yneg(~isnan(xneg));
hold on
% fimplicit(f2, [-10 10 -10 10])
yl = ylim;
xl = xlim;
patch([xpos fliplr(xpos)], [ones(size(ypos))*max(yl) fliplr(ypos) ], 'r')
patch([fliplr(xneg) xneg], [ones(size(yneg))*min(yl) (yneg) ], 'r')
hold off
grid
This is not a straightforward problem, so it could be difficult, especially since the NaN values could be difficult to find and elimiinate, and they are not obvious.
The filled areas are those that conform to the stated inequality.
I evaluated them from -10 to 10 with respect to both variables. Change those to get different results.
  2 个评论
Amith Mallya
Amith Mallya 2021-3-4
编辑:Amith Mallya 2021-3-4
Thanks worked really well, it was more complicated then i had thought.
Star Strider
Star Strider 2021-3-4
As always, my pleasure!
I agree. It was more complicated than I originally thought it would be, as well.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by