I want to draw an implicit form 2-D function.
Show older comments
Hello, I want to draw an implicit form 2-D function.
I can draw other functions like x^2+y^2=4 or x^6+y^6=10000 by using 'ezplot'.
Below is the code.
ezplot('x^6+y^6-10000 = 0', [-10 10 -10 10] );
But, when I try to draw
'0.97*x^6-280.2*x^5+2.9*x^4*y^2-104.38*x^4*y+16060.71*x^4-560.39*x^3*y^2+18788.73*x^3*y+1345683.35*x^3+2.9*x^2*y^4-208.76*x^2*y^3+26602.2*x^2*y^2+210504.82*x^2*y-42416013.17*x^2-280.2*x*y^4+18788.73*x*y^3+121852*x*y^2+13934841.45*x*y-419850783.65*x+0.97*y^6-104.38*y^5+3742.43*y^4-52190.91*y^3+17767421.39*y^2+313145477.65*y = -16025102903.66'
there comes an error 'index exceeds matrix dimensions'
To figure out the reason, I tried with simpler functions.
1)
ezplot('x^6+y^6+x^5+y^5+x^4+y^4+x^3+y^3+x^2+y^2+x+y+x^5*y+x^4*y^2+x^3*y^3+x^2*y^4+y^6-1000000 = 0', [-10 10 -10 10] );
: The curve is drawn exactly.
2)
ezplot('x^6+y^6+x^5+y^5+x^4+y^4+x^3+y^3+x^2+y^2+x+y+x^5*y+x^4*y^2+x^3*y^3+x^2*y^4+y^6-100000000 = 0', [-10 10 -10 10] );
: If the constant number of 1)'s function 1000000 is changed to a larger number like 1000000000
There comes a same error message 'index exceeds matrix dimensions'.
How can I fix this problem?
Thanks
5 Comments
David Goodmanson
on 23 Aug 2017
Hello Hosung, What version of Matlab are you using? On 2017a, when the curve falls outside the plot limits there is a blank plot but no error message. And there is a good plot for
ezplot('0.97*x^6 ... blah blah .... 903.66',[-100 100 -100 100])
Walter Roberson
on 23 Aug 2017
plot limits about [-25 25 -25 25] are appropriate.
Hosung Park
on 24 Aug 2017
David Goodmanson
on 24 Aug 2017
Edited: David Goodmanson
on 24 Aug 2017
I don't see the significance of the +-25 limits, since it appears that the limits need to be around [-60 60 -60 40] in order to catch it all.
Walter Roberson
on 24 Aug 2017
+/- 25 is appropriate for the "2)", function; I did not notice that it was not the same as the first function.
Answers (1)
John D'Errico
on 23 Aug 2017
fxy = @(x,y) 0.97*x.^6-280.2*x.^5+2.9*x.^4.*y.^2-104.38*x.^4.*y+ ...
16060.71*x.^4-560.39*x.^3.*y.^2+18788.73*x.^3.*y+1345683.35*x.^3+ ...
2.9*x.^2.*y.^4-208.76*x.^2.*y.^3+26602.2*x.^2.*y.^2+210504.82*x.^2.*y- ...
42416013.17*x.^2-280.2*x.*y.^4+18788.73*x.*y.^3+121852*x.*y.^2+ ...
13934841.45*x.*y-419850783.65*x+0.97*y.^6-104.38*y.^5+3742.43*y.^4- ...
52190.91*y.^3+17767421.39*y.^2+313145477.65*y + 16025102903.66
fimplicit(fxy,[-25 25 -25 25])

Having said that, this is absolutely the wrong thing to do!!!!!!
It suffers from a common misconception, that you can supply what are surely not the correct coefficients from a high order polynomial model.
For example, look at the first coefficient.
0.97*x.^6
If x can be as large as +/- 25,
25^6
ans =
244140625
So if that first coefficient really lies somewhere in the interval [0.965,0.975], then rounded to 0.97,
[0.965 0.975]*25^6
ans =
2.356e+08 2.3804e+08
So the very first term can vary by a lot. And several of your coefficients are typed as only TWO significant digits.
Then trying to use a tool to solve for an implicit solution can easily yield very different results, just depending on what the real values for those coefficients should have been. This is a terribly common but very bad mistake that people make.
3 Comments
Hosung Park
on 24 Aug 2017
Walter Roberson
on 24 Aug 2017
... Introduced in R2016b
John D'Errico
on 24 Aug 2017
Edited: John D'Errico
on 24 Aug 2017
If you have too old a release, then use ezplot.
ezplot('0.97*x.^6-280.2*x.^5+2.9*x.^4.*y.^2-104.38*x.^4.*y+ 16060.71*x.^4-560.39*x.^3.*y.^2+18788.73*x.^3.*y+1345683.35*x.^3+ 2.9*x.^2.*y.^4-208.76*x.^2.*y.^3+26602.2*x.^2.*y.^2+210504.82*x.^2.*y- 42416013.17*x.^2-280.2*x.*y.^4+18788.73*x.*y.^3+121852*x.*y.^2+ 13934841.45*x.*y-419850783.65*x+0.97*y.^6-104.38*y.^5+3742.43*y.^4-52190.91*y.^3+17767421.39*y.^2+313145477.65*y + 16025102903.66',[-25 25 -25 25])

A similar result. Well, it used a different color in the curve. :)
Better, if we use +- 60 for the limits, we see:
ezplot('0.97*x.^6-280.2*x.^5+2.9*x.^4.*y.^2-104.38*x.^4.*y+ 16060.71*x.^4-560.39*x.^3.*y.^2+18788.73*x.^3.*y+1345683.35*x.^3+ 2.9*x.^2.*y.^4-208.76*x.^2.*y.^3+26602.2*x.^2.*y.^2+210504.82*x.^2.*y- 42416013.17*x.^2-280.2*x.*y.^4+18788.73*x.*y.^3+121852*x.*y.^2+ 13934841.45*x.*y-419850783.65*x+0.97*y.^6-104.38*y.^5+3742.43*y.^4-52190.91*y.^3+17767421.39*y.^2+313145477.65*y + 16025102903.66',[-60 60 -60 60])

Categories
Find more on 선 플롯 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!