文档详情

2022年matlab隐函数绘图相关问题

科***
实名认证
店铺
PDF
48.14KB
约5页
文档ID:315646222
2022年matlab隐函数绘图相关问题_第1页
1/5

MATLAB提供了一个ezplot 函数绘制隐函数图形,下面介绍其用法1) 对于函数f = f(x) ,ezplot 函数的调用格式为:ezplot(f) :在默认区间 -2 x2 绘制 f = f(x) 的图形ezplot(f, a,b) :在区间axb 绘制 f = f(x) 的图形2) 对于隐函数f = f(x,y) , ezplot 函数的调用格式为:ezplot(f) :在默认区间 -2 x2 和-2 y2绘制 f(x,y) = 0 的图形ezplot(f, xmin,xmax,ymin,ymax): 在区间 xminxxmax 和 yminyymax 绘制 f(x,y) = 0 的图形ezplot(f, a,b) :在区间axb 和 ay b 绘制 f(x,y) = 0 的图形3) 对于参数方程x = x(t) 和 y = y(t) ,ezplot 函数的调用格式为:ezplot(x,y) :在默认区间0t2 绘制 x=x(t) 和 y=y(t) 的图形ezplot(x,y, tmin,tmax) :在区间tmin t 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(u2 - v2 - 1,-3,2,-2,3) plots u2 - v2 - 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 ezplot(x2 - y2 - 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 xs, ys and zs are vectors or matrices and the ss are strings. Example: A helix: t = 0:pi/50:10*pi; plot3(sin(t),cos(t),t); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 5 页 - - - - - - - - - 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 对应列元素绘制三维曲线,曲线条数等于矩阵列数例 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 的元素的个数2绘制三维曲面的函数surf 函数和 mesh 函数的调用格式为:mesh(x,y,z,c) surf(x,y,z,c) 一般情况下, x,y,z 是维数相同的矩阵x,y 是网格坐标矩阵,z 是网格点上的高度矩阵,c用于指定在不同高度下的颜色范围。

例 5-17 绘制三维曲面图z=sin(x+sin(y)-x/10 程序如下:x,y=meshgrid(0:0.25:4*pi); z=sin(x+sin(y)-x/10; mesh(x,y,z); axis(0 4*pi 0 4*pi -2.5 1); 此外, 还有带等高线的三维网格曲面函数meshc和带底座的三维网格曲面函数meshz其用法与 mesh 类似, 不同的是meshc还在 xy 平面上绘制曲面在z 轴方向的等高线,meshz还在xy 平面上绘制曲面的底座例 5-18 在 xy 平面内选择区域-8,8-8,8,绘制 4 种三维曲面图名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 5 页 - - - - - - - - - 程序如下:x,y=meshgrid(-8:0.5:8); z=sin(sqrt(x.2+y.2)./sqrt(x.2+y.2+eps); subplot(2,2,1); mesh(x,y,z); title(mesh(x,y,z) subplot(2,2,2); meshc(x,y,z); title(meshc(x,y,z) subplot(2,2,3); meshz(x,y,z) title(meshz(x,y,z) subplot(2,2,4); surf(x,y,z); title(surf(x,y,z) 3标准三维曲面sphere 函数的调用格式为:x,y,z=sphere(n) cylinder 函数的调用格式为:x,y,z= cylinder(R,n) MATLAB还有一个peaks 函数,称为多峰函数,常用于三维曲面的演示。

例 5-19 绘制标准三维曲面图形程序如下:t=0:pi/20:2*pi; x,y,z= cylinder(2+sin(t),30); subplot(2,2,1); surf(x,y,z); subplot(2,2,2); x,y,z=sphere; surf(x,y,z); subplot(2,1,2); x,y,z=peaks(30); surf(x,y,z); 5.4.3 其他三维图形在介绍二维图形时,曾提到条形图、 杆图、饼图和填充图等特殊图形,它们还可以以三维形式出现,使用的函数分别是bar3、stem3、pie3 和 fill3 bar3 函数绘制三维条形图,常用格式为:bar3(y) bar3(x,y) stem3 函数绘制离散序列数据的三维杆图,常用格式为:stem3(z) stem3(x,y,z) pie3 函数绘制三维饼图,常用格式为:pie3(x) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 5 页 - - - - - - - - - fill3 函数等效于三维函数fill ,可在三维空间内绘制出填充过的多边形,常用格式为:fill3(x,y,z,c) 例 5-20 绘制三维图形:(1) 绘制魔方阵的三维条形图。

2) 以三维杆图形式绘制曲线y=2sin(x) 3) 已知 x=2347,1827,2043,3025 ,绘制饼图4) 用随机的顶点坐标值画出五个黄色三角形程序如下:subplot(2,2,1); bar3(magic(4) subplot(2,2,2); y=2*sin(0:pi/10:2*pi); stem3(y); subplot(2,2,3); pie3(2347,1827,2043,3025); subplot(2,2,4); fill3(rand(3,5),rand(3,5),rand(3,5), y ) 例 5-21 绘制多峰函数的瀑布图和等高线图程序如下:subplot(1,2,1); X,Y ,Z=peaks(30); waterfall(X,Y,Z) xlabel(X-axis),ylabel(Y-axis),zlabel(Z-axis); subplot(1,2,2); contour3(X,Y,Z,12,k); %其中 12 代表高度的等级数xlabel(X-axis),ylabel(Y-axis),zlabe。

下载提示
相似文档
正为您匹配相似的精品文档
相关文档