how can I find the rang of a function to plot with ezplot?

I want to plot "a^2+1406.25*b^2-a*b=1" with "ezplot" but plot window doesn't show any figure

 Accepted Answer

MATLAB does successfully plot that, but it seems to choose the default axes poorly. Try this:

figure
ezplot('a^2+1406.25*b^2-a*b=1',[-1.1 1.1],[-0.03 0.03])

Here's the result I got:

8 Comments

tnx and how did you find this axis?
I did it pretty manually. I did the plot at first without it, and zoomed in to find better values.
ezplot is pretty smart in its choice of axis limits, USUALLY, but not always. This may be a case where the disparate axis scaling that would be necessary screws up the algorithm.
I have to draw many figure for example: 47103.658*b+a^2+228.658*b^2-15.122*a*b=1 47103.658*b+a^2+228.658*b^2-15.122*a*b+48660=1 a^2+1406.25*b^2-a*b+48660=1 and for those I can't find the appropriate axis

There is some other weirdness that I have not figured out. I would expect the following code to produce the same figure.

figure
ezplot('a^2+1406.25*b^2-a*b=1')
xlim([-1.1 1.1])
ylim([-0.03 0.03])

Instead, it produces this ...

Not weird at all. ezplot is actually a simple trick. It is a contour plotting routine!
h = ezplot('a^2+1406.25*b^2-a*b=1')
h =
Contour with properties:
LineColor: 'flat'
LineStyle: '-'
LineWidth: 0.5
Fill: 'off'
LevelList: 0
XData: [1x251 double]
YData: [251x1 double]
ZData: [251x251 double]
ezplot just generates a grid of points, then throws contour at it, looking for the level set at z==0. But look at the axes.
[min(h.XData),max(h.XData)]
ans =
-6.2832 6.2832
>> [min(h.YData),max(h.YData)]
ans =
-6.2832 6.2832
The problem is as I have said before. There are only a few points on that ellipse in the y-direction. It is simply unable to adequately resolve the shape of that curve on those ends.
By setting the limits in advance, you enable the plot to be adequately resolved.
Again, the problem with ezplot is when you throw something at it that really needs very disparate axis limits.
I've barely used ezplot before today, so obviously I have something to learn about it. I would have expected the two code snippets I posted to behave identically, because I thought the version I posted first was just a more compact syntax for the same instructions.
Obviously not!
I actually love ezplot. It is a simple tool that works often, though sometimes it needs some coaxing. Any software needs thatat times though.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!