Plotting implicit equation with fimplicit

조회 수: 1 (최근 30일)
Jay
Jay 2019년 2월 11일
댓글: Torsten 2019년 2월 11일
Hello
I have tried to plot this implicit equation. But when I tried it, the plot is showing empty.
Here is the code I used to plot. Could anyone help me with this.
Thanks in advance
clc
syms f(x,y)
n = 8;
a1 = 1.0086*y - 0.9216*(x - y);
b1 = 1.0107*(-x) - 1.0086*(y);
c1 = 0.9216*(x - y) - 1.0107*(-x);
h1 = 0.5877*(161.65);
I3 = ((a1.* b1.*c1)/(54))-((b1.*(h1.^2))/(6));
I2 = ((h1.^2)/(3))+((a1.^2 + b1.^2 + c1.^2)/(54));
th = acos(I3/(I2.^(3/2)));
v1 = ((2*th)+pi)/6;
an1 = (abs(2*cos(v1)))^n;
an2 = (abs(2*cos((2*th+3*pi)/6)))^n;
an3 = (abs(2*cos((2*th+5*pi)/6)))^n;
f(x,y) = ((3*I2).^(n/2)) * (an1 + an2 + an3) - (2*(189.32)^8);
fimplicit(f)

채택된 답변

Torsten
Torsten 2019년 2월 11일
function main
fimplicit (@(x,y)f(x,y))
end
function fun = f(x,y)
n = 8;
a1 = 1.0086*y - 0.9216*(x - y);
b1 = 1.0107*(-x) - 1.0086*(y);
c1 = 0.9216*(x - y) - 1.0107*(-x);
h1 = 0.5877*(161.65);
I3 = ((a1.* b1.*c1)/(54))-((b1.*(h1.^2))/(6));
I2 = ((h1.^2)/(3))+((a1.^2 + b1.^2 + c1.^2)/(54));
th = acos(I3./(I2.^(3/2)));
v1 = ((2*th)+pi)/6;
an1 = (abs(2*cos(v1))).^n;
an2 = (abs(2*cos((2*th+3*pi)/6))).^n;
an3 = (abs(2*cos((2*th+5*pi)/6))).^n;
fun = ((3*I2).^(n/2)).* (an1 + an2 + an3) - (2*(189.32)^8);
end
Resonable limits for plotting are required - no zeros are found in the default range [-5:5] for x and y.
  댓글 수: 6
Jay
Jay 2019년 2월 11일
편집: Jay 2019년 2월 11일
Hello Torsten
It works. But it is not working with other limits. Can you explain why so?
Thank you.
Torsten
Torsten 2019년 2월 11일
It "works" as long as the object is contained in the box defined by the specified limits for x and y.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

John D'Errico
John D'Errico 2019년 2월 11일
편집: John D'Errico 2019년 2월 11일
Easy enough. Try this, for example.
vpasolve(f(1,y))
ans =
-80.224189505722446658042301607259
vpasolve(f(-20,y))
ans =
63.634253282860063957543062643774
Hmm. So [1,-80] is roughly a solution. That should be a good hint as to where to have fimplicit look.
fimplicit(f,[-150,150,-150,150])
axis equal
grid on
The problem was fimplicit looks by default in a rather narrow set of limits on x and y. It cannot know where it SHOULD be looking, and computer programs can sometimes be so clueless. Since fimplicit just found no solutions at all in the domain it was looking by default, you saw an empty figure. Sometimes you need to give even a computer a nudge in the right direction.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by