MATLAB提供了一个ezplot函数绘制隐函数图形,下面介绍其用法。
(1) 对于函数f = f(x),ezplot函数的调用格式为:
ezplot(f):在默认区间-2π<x<2π绘制f = f(x)的图形。
ezplot(f, [a,b]):在区间a<x<b绘制f = f(x)的图形。
(2) 对于隐函数f = f(x,y),ezplot函数的调用格式为:
ezplot(f):在默认区间-2π<x<2π和-2π<y<2π绘制f(x,y) = 0的图形。
ezplot(f, [xmin,xmax,ymin,ymax]):在区间xmin<x<xmax和ymin<y<ymax绘制f(x,y) = 0的图形。
ezplot(f, [a,b]):在区间a<x<b和a<y< b绘制f(x,y) = 0的图形。
(3) 对于参数方程x = x(t)和y = y(t),ezplot函数的调用格式为:
ezplot(x,y):在默认区间0<t<2π绘制x=x(t)和y=y(t)的图形。
ezplot(x,y, [tmin,tmax]):在区间tmin < t < tmax绘制x=x(t)和y=y(t)的图形。
例5-15 隐函数绘图应用举例。
程序如下:
subplot(2,2,1);
ezplot('x^2+y^2-9');axis equal
subplot(2,2,2);
ezplot('x^3+y^3-5*x*y+1/5')
subplot(2,2,3);
ezplot('cos(tan(pi*x))',[ 0,1])
subplot(2,2,4);
ezplot('8*cos(t)','4*sqrt(2)*sin(t)',[0,2*pi])
在MATLAB7.0用帮忙命令可以清楚知道函数的意义与用法.
如:::
>> help ezplot
EZPLOT Easy to use function plotter.
    EZPLOT(f) plots the expression f = f(x) over the default
    domain -2*pi < x < 2*pi.
    EZPLOT(f, [a,b]) plots f = f(x) over a < x < b
    For implicitly defined functions, f = f(x,y)
    EZPLOT(f) plots f(x,y) = 0 over the default domain
    -2*pi < x < 2*pi and -2*pi < y < 2*pi
    EZPLOT(f, [xmin,xmax,ymin,ymax]) plots f(x,y) = 0 over
    xmin < x < xmax and ymin < y < ymax.
    EZPLOT(f, [a,b]) plots f(x,y) = 0 over a < x < b and a < y < b.
    If f is a function of the variables u and v (rather than x and y), then
    the domain endpoints a, b, c, and d are sorted alphabetically. Thus,
    EZPLOT('u^2 - v^2 - 1',[-3,2,-2,3]) plots u^2 - v^2 - 1 = 0 over
    -3 < u < 2, -2 < v < 3.
    EZPLOT(x,y) plots the parametrically defined planar curve x = x(t)
    and y = y(t) over the default domain 0 < t < 2*pi.
    EZPLOT(x,y, [tmin,tmax]) plots x = x(t) and y = y(t) over
    tmin < t < tmax.
    EZPLOT(f, [a,b], FIG), EZPLOT(f, [xmin,xmax,ymin,ymax], FIG), or
    EZPLOT(x,y, [tmin,tmax], FIG) plots the given function over the
    specified domain in the figure window FIG.
    Examples
    f is typically an expression, but it can also be specified
    using @ or an inline function:
      ezplot('cos(x)')
      ezplot('cos(x)', [0, pi])
      ezplot('1/y-log(y)+log(-1+y)+x - 1')
      ezplot('x^2 - y^2 - 1')
      ezplot('x^2 + y^2 - 1',[-1.25,1.25]); axis equal
      ezplot('x^3 + y^3 - 5*x*y + 1/5',[-3,3])
      ezplot('x^3 + 2*x^2 - 3*x + 5 - y^2')
      ezplot('sin(t)','cos(t)')
      ezplot('sin(3*t)*cos(t)','sin(3*t)*sin(t)',[0,pi])
      ezplot('t*cos(t)','t*sin(t)',[0,4*pi])
      f = inline('cos(x)+2*sin(x)');
      ezplot(f)
      ezplot(@humps)
    See also EZCONTOUR, EZCONTOURF, EZMESH, EZMESHC, EZPLOT3,
            EZPOLAR, EZSURF, EZSURFC, PLOT.
Overloaded methods
    help sym/ezplot.m
>>
>> ezplot('x^2 - y^2 - 1')
这是绘制双曲线.
三维图形的绘制也是一样.可以用
>> help plot3
PLOT3 Plot lines and points in 3-D space.
    PLOT3() is a three-dimensional analogue of PLOT().
    PLOT3(x,y,z), where x, y and z are three vectors of the same length,
    plots a line in 3-space through the points whose coordinates are the
    elements of x, y and z.
    PLOT3(X,Y,Z), where X, Y and Z are three matrices of the same size,
    plots several lines obtained from the columns of X, Y and Z.
    Various line types, plot symbols and colors may be obtained with
    PLOT3(X,Y,Z,s) where s is a 1, 2 or 3 character string made from
    the characters listed under the PLOT command.
    PLOT3(x1,y1,z1,s1,x2,y2,z2,s2,x3,y3,z3,s3,...) combines the plots
    defined by the (x,y,z,s) fourtuples, where the x's, y's and z's are
    vectors or matrices and the s's are strings.
    Example: A helix:
        t = 0:pi/50:10*pi;
        plot3(sin(t),cos(t),t);
    PLOT3 returns a column vector of handles to LINE objects, one
    handle per line. The X,Y,Z triples, or X,Y,Z,S quads, can be
    followed by parameter/value pairs to specify additional
    properties of the lines.
    See also PLOT, LINE, AXIS, VIEW, MESH, SURF.
>>
plot3函数与plot函数用法十分相似,其调用格式为:
plot3(x1,y1,z1,选项1,x2,y2,z2,选项2,…,xn,yn,zn,选项n)
其中每一组x,y,z组成一组曲线的坐标参数,选项的定义和plot函数相同。当x,y,z是同维向量时,则x,y,z 对应元素构成一条三维曲线。当x,y,z是同维矩阵时,则以x,y,z对应列元素绘制三维曲线,曲线条数等于矩阵列数。
matlab等高线填充颜例5-16 绘制三维曲线。
程序如下:
t=0:pi/100:20*pi;
x=sin(t);
y=cos(t);
z=t.*sin(t).*cos(t);
plot3(x,y,z);
title('Line in 3-D Space');
xlabel('X');ylabel('Y');zlabel('Z');
grid on;
5.4.2 三维曲面
1.产生三维数据
在MATLAB中,利用meshgrid函数产生平面区域内的网格坐标矩阵。其格式为:
x=a:d1:b; y=c:d2:d;
[X,Y]=meshgrid(x,y);
语句执行后,矩阵X的每一行都是向量x,行数等于向量y的元素的个数,矩阵Y的每一列都是向量y,列数等于向量x的元素的个数。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。