Plotting implicit equation with fimplicit

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)

 Akzeptierte Antwort

Torsten
Torsten am 11 Feb. 2019

0 Stimmen

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 Kommentare

Jay
Jay am 11 Feb. 2019
Hello Torsten
I tried this code. But the plot shown is empty.
Best Regards
Jay
Stephan
Stephan am 11 Feb. 2019
fsurf(@(x,y)f(x,y))
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
Jay
Jay am 11 Feb. 2019
Hello
I tried it. As expected it is showing 3D surface. But I am interested in 2D curve. Could you please suggest an alternate way.
Best Regards
Jay
Torsten
Torsten am 11 Feb. 2019
fimplicit (@(x,y)f(x,y),[-200 200 -150 150])
Jay
Jay am 11 Feb. 2019
Bearbeitet: Jay am 11 Feb. 2019
Hello Torsten
It works. But it is not working with other limits. Can you explain why so?
Thank you.
Torsten
Torsten am 11 Feb. 2019
It "works" as long as the object is contained in the box defined by the specified limits for x and y.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

John D'Errico
John D'Errico am 11 Feb. 2019
Bearbeitet: John D'Errico am 11 Feb. 2019

0 Stimmen

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.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018b

Gefragt:

Jay
am 11 Feb. 2019

Kommentiert:

am 11 Feb. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by