开发者

uncomplete ezplot drawing

why when i use ezplot in for example [1 1.5] interval, a discontinuity will appear in some piec开发者_如何转开发es of lines but when i use a closer interval like [1.3 1.5], the discontinuity will be annihilated?


EZPLOT is a general purpose plotting function that will automatically select a set of points at which to evaluate and plot the function you pass to it. Most of the time, things work fine. But there are some special cases where EZPLOT can have some trouble. It may not render well near discontinuities or points where there are rapid changes in the function (which it may mistake for a discontinuity).

That's the drawback of a function that is designed to be general enough to accept any function you give it: it's hard to make it general enough to handle everything exactly right, so some special edge cases look a little funny. In such cases, you should avoid functions like EZPLOT (which make a lot of choices for you) and plot things yourself by evaluating your functions at points you choose and plotting those points using the PLOT function. Here's a helpful link for this.


The problem is that ezplot() is useful, but not that robust.

A better option for plotting a function without discrete points is fplot(). Check out the documentation for it.

Here is an example of how to use it compared with ezplot():

lowerBound = 0;
upperBound = 1;

%# The ezplot way:
ezplot('y=sin(1/x)',[lowerBound,upperBound,-1,1])

%# The fplot way:
fplot('sin(1/x)',[lowerBound,upperBound])

fplot() will evaluate more points where the function changes more rapidly. Thus discontinuities will still cause problems in the graph if you look closely, but it will try harder to plot them accurately.

To plot a level curve of a function with three variables requires a little more typing:

%# First create a grid where you want the function to be drawn
[x,y]=meshgrid(-2:.01:2);
     %# Remember that -2:.01:2 creates a vector with values from -2 to 2
     %# in steps of .01

%# Then define your function
z=-3*y./(x.^2+y.^2+1);

%# Now graph the level curve of the function.  I chose the level z=0.5:
contour(x,y,z,[0.5])
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜