matlab教学教案课件第五章+符号数学基础_第1页
matlab教学教案课件第五章+符号数学基础_第2页
matlab教学教案课件第五章+符号数学基础_第3页
matlab教学教案课件第五章+符号数学基础_第4页
matlab教学教案课件第五章+符号数学基础_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第五章 符号数学基础Chapter 5:Foundation of Symbolic Mathematics 带有符号变量、表达式的运算称为抽象计算即符号计算,MATLAB借助于MAPLE的特长,建立了强大的符号运算功能。一、数据类型(Symbolic array model)1、 字符串数组(string)在MATLAB中几个字符(character)可以构成一个字符串(string),一个字符串被视为一个行向量(Row Vector),字符串中的每一个字符(包括空格)以ASCII码的形式存放于此向量的每一个元素(Element)中。一个字符串是由单引号括起来的简单文本。1.1一维字符串数组:例1:t=How about this character string size(t) %查询whos1.2、二维字符串数组:1)简单输入:数组每一行的字符个数相等的情况下,可简单直接输入,如不等需加空字符补齐。例1name=matlab;maple 2)char函数输入:char函数可以将不同长度的字符串自动创建每行自负数都相等的数组,各行都被自动用空字符补成与最长字符串相等的字数。例2s=char(How,about,this,character,string)1.3、字符数组与单元数组的转换利用cellstr函数可以字符数组转换为单元数组:例1s=Symbolic;array ;model d=cellstr(s)对于用cellstr函数处理过的数组,还可以用char函数将其转换为原来的字符数组。例2s=Symbolic;array ;model d=cellstr(s)s=char(d)1.4、字符串的比较:两个用于字符串比较的函数:strcmp,比较两个输入字符串是否相等strncmp,比较两个输入字符串的前几个字符是否相等例1str1=hellow;str2=helpa=strcmp(str1,str2)c=strncmp(str1,str2,3)当这两个函数用于单元数组时,会按单元一次执行。例2A=pizza,chips,candyB=pizza,chrocolate,candystrcmp(A,B)strnmp(A,B,2)1.5、字符串中字符的分类:两个用于字符串中的字符分类函数isletter,判定字符串中字符是否字母isspace,判定字符串中的字符是否是空白字符例1str1=hellow;str2=helpisletter(str1)isspace(str2)1.6、查找和替换:strrep(a,b,c)函数用来对字符串中的字符进行查找和替换,运行结果是用c代替a中的b。A=I am a boyB=boyC=girlnew=strrep(A,B,C)*字符串、数值与数组的转换 :num2str,把数值转换成字符串int2str,把整数转换成字符串dec2hex,把十进制数值转换成十六进制的字符串mat2str,将矩阵转换为字符串,(运用eval命令可以将字符串在变回原先的矩阵)2、细胞数组(Cell Array) 可用来存放任何类型及任何大小的数组,而且同一个细胞数组中各细胞的内容可以不同。例1:三种细胞数组的创建方法:1) 单元索引t(1,1)=i am a boyt(1,2)=5*6+62t(2,1)=1 3 2 4 5 6t(2,2)=tom,yonkers2)内容索引:t1,1=I am a boyt1,2=3*673t2,1=1 2 4 1 5 7 t2,2=tom,yonkers3) 方法: 将所有的元素内容一次填入大括号完成t=I am a boy,6*72;2 3 1 4 5,tom,peiking3、 结构数组(Structure Array) 与细胞数组相似结构数组也能在一个数组中存放各类数据,而其组织数据的能力比细胞数组更强,更富于变化。结构数组的创建:每个结构数组都包含有数个字段,每个字段又可以包含各个不同类型的数据。例1: =kim student.id=1253436 student.sex=male student.age=24其中student即代表一个结构,可以自由的向结构数组中加入元素。 例2:student(2).name=grees student(2).id=0934523 student(2).sex=female student(2).age=22还可以使用struct命令建立结构数组:例3:tcell=cell(3,4) %建立mxn阶空细胞数组tstruct=struct(name,tcell,age,tcell,course,tcell)二 符号对象的创建(Creating a symbolic object)1. 创建符号变量和表达式(Creating a symbolic variable and expression)创建符号变量和表达式的两个基本函数:sym, syms*x=sym(x) 创建一个符号变量x,可以是字符、字符串、表达式或字符表达式。*syms用于方便地一次创建多个符号变量,调用格式为: syms a b c d . 书写简洁意义清楚,建议使用。例1:使用sym函数创建符号变量.a=sym(a)b=sym( hello)c=sym( (1+sqrt(5)/2)y=sym( x3+5*x2+12*x+20)a =ab = helloC = (1+sqrt(5)/2 Y =x3+5*x2+12*x+20例2:用syms函数创建符号变量。syms a b c d z=a2+sin(b)-3*c/d2. 创建符号矩阵(Symbolic matrix Creating)例1:创建一个循环矩阵。syms a b c dn=a b c d;b c d a;c d a b;d a b cn = a, b, c, d b, c, d, a c, d, a, b d, a, b, c利用sym 函数可将矩阵转换为符号矩阵。例2:将3阶Hilbert 矩阵转换为符号矩阵 h=hilb(3)h1=sym(h)h = 1.0000 0.5000 0.3333 0.5000 0.3333 0.2500 0.3333 0.2500 0.2000h1 = 1, 1/2, 1/3 1/2, 1/3, 1/4 1/3, 1/4, 1/5注意符号矩阵于数值矩阵的区别。3. 默认符号变量(Implied symbolic variable)在MATLAB的符号数学工具箱中,以最接近x的顺序排列默认自变量的顺序,可利用findsym函数对默认自变量进行查询。例1: 求符号函数在不同自变量情况下的结果。 创建符号变量x和n,建立函数f=xn,然后分别求f对x和f对n的导数. syms x nf=xndiff(f) % x作为自变量,求f对x的导数diff(f,n) % n作为自变量,求f对n的导数f =xnans = xn*n/x ans =xn*log(x)例2: 查询符号函数中的默认自变量。创建符号变量 a,b, n, x 和t ,建立函数f=axn+bt,然后求f的默认自变量。syms a b n t xf=a*xn+b*tfindsym(f,1)findsym(f,2)findsym(f,5) % f表达式中按最接近x顺序排列的5个默认自变量findsym(f) % f表达式中按最接近字母顺序排列的全部自变量f = a*xn+b*t ans =xans =x,tans =x,t,n,b,aans =a, b, n, t, x三 符号表达式的化简和替换(simplifying and replacing of Symbolic expressions) 符号数学工具箱提供的符号表达式的因式分解、展开、合并、化简、通分等操作:1. 符号表达式的化简(Simplifying of symbolic expression)(1).因式分解(Factorization)符号表达式的因式分解函数为 factor(S), 可分解符号表达式S的各个元素。例1: 对表达式f=x9-1进行因式分解。syms x f=factor(x9-1)pretty(f)f =(x-1)*(x2+x+1)*(x6+x3+1) 2 6 3 (x - 1) (x + x + 1) (x + x + 1)例2:对大整数12345678901234567890进行因式分解。factor(sym(12345678901234567890)ans = (2)*(3)2*(5)*(101)*(3803)*(3607)*(27961)*(3541)(2)符号表达式的展开(Expanding of symbolic expressions)符号表达式的展开函数为expand(S), 此函数因数展开符号表达式S.例1: 展开表达式f=(x+1)5和f=sin(x+y) syms x yf=(x+1)5;expand(f)f=sin(x+y);expand(f)ans = x5+5*x4+10*x3+10*x2+5*x+1 ans = sin(x)*cos(y)+cos(x)*sin(y)(3).符号表达式的同类项合并(Similar team merging for symbolic expression)符号表达式的同类项合并函数为 collect(S,n),此函数将符号表达式中自变量的同次幂项的系数合并。例1:对于表达式f=x(x(x-6)+12)t, 分别将自变量x和t的同类项合并。 syms x tf=x*(x*(x-6)+12)*t;collect(f)collect(f,t)ans =t*x3-6*t*x2+12*t*x ans =x*(x*(x-6)+12)*tCOLLECT Collect coefficients.COLLECT(S,v) regards each element of the symbolic matrix S as a polynomial in v and rewrites S in terms of the powers of v.COLLECT(S) uses the default variable determined by FINDSYM. (4). 符号表达式的化简(Simplifying of symbolic expression)符号表达式的两个化简函数:simplify, simple ,simplify:化简函数,可用于化简各种表达式 例1:对表达式f=sin2(x)+cos2(x)进行化简.syms xf=sin(x)2+cos(x)2;simplify(f)ans = 1r,how=simple(S) 函数可寻找符号表达式S的最简型, r为返回的简化形式,how为化简过程中使用的主要方法,simple函数综合使用了下列化简方法:*simplify 函数对表达式进行化简*radsimp 函数对含根式(surd)的表达式进行化简*combine 函数对表达式中以求和、乘积、幂运算等形式出现的项进行合并*collect 合并同类项*factor 函数实现因式分解*convert 函数完成表达式形式的转换例2:最简表达式的获得。syms x tf=cos(x)2-sin(x)2;r,how=simple(f)r =cos(2*x)how =combine(5)符号表达式的分式通分(Reduction symbolic expression to common denominator)符号表达式的分式通分函数为 n,d=numden(S), 此函数将符号表达式转换为分子(Numerator)和分母(denominator)都是正系数的最佳多项式。例1:对表达式 f=x/y+y/x 进行通分。 syms x yf=x/y+y/x;n,d=numden(f)n = x2+y2d = y*xNUMDEN Numerator and denominator of a symbolic expression.N,D = NUMDEN(A) converts each element of A to a rational form where the numerator and denominator are relatively prime polynomials with integer coefficients.(6) 符号表达式的嵌套形式重写(Representation of nested symbolic expression)符号表达式的嵌套形式重写函数为 horner(S), 此函数将符号表达式转换为嵌套形式。 例1: 对表达式f=x3+6x2+11x-6进行嵌套形式重写。 syms xf=x3+6*x2+11*x-6;horner(f)ans =-6+(11+(6+x)*x)*xHORNER Horner polynomial representation.HORNER(P) transforms the symbolic polynomial P into its Horner, or nested, representation.2. 符号表达式的替换(Replacing of symbolic expression)MATLAB 的符号数学工具箱提供了两个符号表达式的替换函数subexpr 和subs,可通过符号替换使表达式的输出形式简化。subexpr函数可将表达式中重复出现的字符串用变量代替。调用格式:Y,SIGMA=subexpr(S,SIGMA): 用变量SIGMA的值代替符号表达式S中重复出现的字符串,Y返回替换后的结果。例1:求解并化简三次方程x3+ax+1=0的符号解。 t=solve(x3+a*x+1=0)r,s=subexpr(t,s)t = 1/6*(-108+12*(12*a3+81)(1/2)(1/3)-2*a/(-108+12*(12*a3+81)(1/2)(1/3) -1/12*(-108+12*(12*a3+81)(1/2)(1/3)+a/(-108+12*(12*a3+81)(1/2)(1/3)+1/2*i*3(1/2)*(1/6*(-108+12*(12*a3+81)(1/2)(1/3)+2*a/(-108+12*(12*a3+81)(1/2)(1/3) -1/12*(-108+12*(12*a3+81)(1/2)(1/3)+a/(-108+12*(12*a3+81)(1/2)(1/3)-1/2*i*3(1/2)*(1/6*(-108+12*(12*a3+81)(1/2)(1/3)+2*a/(-108+12*(12*a3+81)(1/2)(1/3)r = 1/6*s(1/3)-2*a/s(1/3) -1/12*s(1/3)+a/s(1/3)+1/2*i*3(1/2)*(1/6*s(1/3)+2*a/s(1/3) -1/12*s(1/3)+a/s(1/3)-1/2*i*3(1/2)*(1/6*s(1/3)+2*a/s(1/3)s =-108+12*(12*a3+81)(1/2)函数subs是用指定符号替换符号表达式中的某一特定符号,调用格式为:R=subs(S,old,new), 它可用新的符号变量new替换原来符号表达式S中的old. 当new为数值形式时,显示的结果虽然是数值,但它事实上是符号变量。例2:分别用新变量替换表达式a+b和cos(a)+sin(b)中变量。 syms a bsubs(a+b,a,4)subs(cos(a)+sin(b), a,b,sym(alpha),2) %用单元数组完成不同性质%元素的替换ans =4+bans = cos(alpha)+sin(2)四符号微积分(Differential and integral calculus)1. 符号极限(Symbolic limit)*limit(F,x,a) 计算符号表达式F在xa条件下的极限;*limit(F,a) 计算符号表达式F中由默认自变量趋向于a条件下的极限;*limit(F,) 计算符号表达式F在默认自变量趋向于0条件下的极限;*limit(F,x,a,right) 和limit(F,x,a,left) 计算符号表达式F在xa条件下的右极限和左极限。例1:分别计算表达式, , 及和 syms x a;limit(sin(x)/x)limit(1/x,x,0,right)limit(1/x,x,0,left)v=(1+a/x)x,exp(-x);limit(v,x,inf,left) ans =1ans =inf ans = -infans = exp(a), 02. 符号微分(symbolic differential calculus)*diff(S) 求符号表达式S对于默认自变量的微分;*diff(S,v) 求符号表达式S对于自变量v的微分;*diff(S,n) 求符号表达式S对于默认自变量的n次微分;*diff(S,v,n) 求符号表达式S对于自变量v的n次微分; 如果S是符号变量或数组,diff(S)对数组内的各个元素进行微分。如果diff的表达式或可变参量是数值,MATLAB就其数值差分,如果参量是符号字符串或变量,MATLAB就对其表达式进行微分。例1: 分别计算表达式f=xx的导数和3次导数. syms x; f=xx;diff(f)diff(f,3)ans = xx*(log(x)+1) ans = xx*(log(x)+1)3+3*xx*(log(x)+1)/x-xx/x23. 符号积分(Symbolic integral calculus)*int(S) 求符号表达式S对于默认自变量的不定积分; *int(S,v) 求符号表达式S对于自变量v的不定积分;*int(S,a,b) 求符号表达式S对于默认自变量从a到b的定积分;*int(S,v,a,b) 求符号表达式S对于自变量v从a到b的定积分;*int(S,m,n) 求符号表达式S对预设自变量v的积分值,积分区间为m,n,m和n 是符号表达式。 例1:分别计算表达式、 和。 syms x z;f=-2*x/(1+x2)2;int(f)f=x/(1+z2);int(f)int(f,z)f=x*log(1+x);int(f,0,1)ans =1/(1+x2)ans =1/2*x2/(1+z2) ans = x*atan(z)ans =1/44. 符号求和(Symbolic summation)*symsum(S) 求符号表达式S对于默认自变量的不定和; * symsum(S,v) 求符号表达式S对于自变量v的不定和;* symsum(S,a,b) 求符号表达式S对于默认自变量从a到b的有限和;例1: 分别计算表达式k,和 syms k xsymsum(k)symsum(k2,0,10)symsum(xk/sym(k!),k,0,inf)ans =1/2*k2-1/2*kans =385 ans =exp(x)5 .Taylor级数展开(Taylor series expanding)*Taylor(f) 计算符号表达式f对于默认自变量等于0 处的5阶taylor级数展开式; *taylor(f,n,v) 计算符号表达式f在自变量v=0处的n-1阶Taylor级数展开式;*taylor(f,n,v,a) 计算符号表达式f在自变量v=a 处的n-1阶Taylor 级数展开式。例1: 分别计算表达式 的5 阶Taylor级数展开式和f=exsin(x) 的5 阶及12 阶Taylor级数展开式。 syms xf=1/(5+cos(x);r=taylor(f)f=exp(x*sin(x);r=taylor(f,12)r=taylor(f)r = 1/6+1/72*x2 r = 1+x2+1/3*x4+1/120*x6-11/560*x8-1079/362880*x10 r = 1+x2+1/3*x4五. 符号方程的求解(Symbolic equation solution)1 . 符号代数方程及方程组(线性和非线性)的求解(symbolic algebra equations set solution)*g=solve(eq) 求解符号表达式eq=0的代数方程,自变量为默认自变量;*g=solve(eq,var) 求解符号表达式eq=0的代数方程,自变量为var;*g=solve(eq1,eq2,eqn,var1,var2,varn)求解符号表达式eq1,eq2,eqn组成的代数方程组,自变量分别为var1,var2,varn。例1:分别求解代数方程ax2+bx+c=0和cos(2x)+sin(x)=1 syms a b c x s=a*x2+b*x+c;solve(s)solve(cos(2*x)+sin(x)=1)ans = 1/2/a*(-b+(b2-4*a*c)(1/2) 1/2/a*(-b-(b2-4*a*c)(1/2)ans = 0 pi 1/6*pi 5/6*pi例2:求解代数方程组x2-y2+z=10, x+y-5z=0, 2x-4y+z=0 syms x y zf=x2-y2+z-10;g=x+y-5*z;h=2*x-4*y+z;x,y,z=solve(f,g,h) %以数值数组形式输出求解结果S=solve(f,g,h); %缺省情况将方程组的解存放在结构变量中S.x,S.y,S.zx = -19/80+19/240*2409(1/2) -19/80-19/240*2409(1/2)y = -11/80+11/240*2409(1/2) -11/80-11/240*2409(1/2) z = -3/40+1/40*2409(1/2) -3/40-1/40*2409(1/2)ans =-19/80+19/240*2409(1/2), -11/80+11/240*2409(1/2), -3/40+1/40*2409(1/2) -19/80-19/240*2409(1/2), -11/80-11/240*2409(1/2), -3/40-1/40*2409(1/2)SOLVE Symbolic solution of algebraic equations. SOLVE(eqn1,eqn2,.,eqnN) SOLVE(eqn1,eqn2,.,eqnN,var1,var2,.,varN) SOLVE(eqn1,eqn2,.,eqnN,var1,var2,.varN) The eqns are symbolic expressions or strings specifying equations. Thevars are symbolic variables or strings specifying the unknown variables.SOLVE seeks zeros of the expressions or solutions of the equations. If not specified, the unknowns in the system are determined by FINDSYM.If no analytical solution is found and the number of equations equals the number of dependent variables, a numeric solution is attempted.Three different types of output are possible. For one equation and oneoutput, the resulting solution is returned, with multiple solutions to a nonlinear equation in a symbolic vector. For several equations and an equal number of outputs, the results are sorted in lexicographic order and assigned to the outputs. For several equations and a single output, a structure containing the solutions is returned.Examples:solve(p*sin(x) = r) chooses x as the unknown and returns ans = asin(r/p) x,y = solve(x2 + x*y + y = 3,x2 - 4*x + 3 = 0) returns x = 1 3 y = 1 -3/2 S = solve(x2*y2 - 2*x - 1 = 0,x2 - y2 - 1 = 0) returns the solutions in a structure. S = x: 8x1 sym y: 8x1 sym u,v = solve(a*u2 + v2 = 0,u - v = 1) regards a as a parameter and solves the two equations for u and v. S = solve(a*u2 + v2,u - v = 1,a,u) regards v as aparameter, solves the two equations, and returns S.a and S.u.a,u,v = solve(a*u2 + v2,u - v = 1,a2 - 5*a + 6) solves the three equations for a, u and v.a = 2 2 3 3u = 1/3+1/3*i*2(1/2) 1/3-1/3*i*2(1/2) 1/4+1/4*i*3(1/2) 1/4-1/4*i*3(1/2)v = -2/3+1/3*i*2(1/2) -2/3-1/3*i*2(1/2) -3/4+1/4*i*3(1/2) -3/4-1/4*i*3(1/2)FSOLVE Solves nonlinear equations by a least squares method. FSOLVE solves equations of the form: F(X)=0 where F and X may be vectors or matrices. X=FSOLVE(FUN,X0) starts at the matrix X0 and tries to solve the equations in FUN. FUN accepts input X and returns a vector (matrix) of equation values F evaluated at X. X=FSOLVE(FUN,X0,OPTIONS) minimizes with the default optimization parameters replaced by values in the structure OPTIONS, an argument created with the OPTIMSET function.See OPTIMSET for details. Used options are Display, TolX, TolFun, DerivativeCheck, Diagnostics, Jacobian, JacobMult, JacobPattern, LineSearchType, LevenbergMarquardt, MaxFunEvals, MaxIter, DiffMinChange and DiffMaxChange, LargeScale, MaxPCGIter, PrecondBandWidth, TolPCG, TypicalX. Use the Jacobian option to specify that FUN also returns a second output argument J that is the Jacobian matrix at the point X. If FUN returns a vector F of m components when X has length n, then J is an m-by-n matrix where J(i,j) is the partial derivative of F(i) with respect to x(j). (Note that the Jacobian J is the transpose of the gradient of F.)X=FSOLVE(FUN,X0,OPTIONS,P1,P2,.) passes the problem-dependent parameters P1,P2,. directly to the function FUN: FUN(X,P1,P2,.). Pass an empty matrix for OPTIONS to use the default values. X,FVAL=FSOLVE(FUN,X0,.) returns the value of the objective function at X. X,FVAL,EXITFLAG=FSOLVE(FUN,X0,.) returns a string EXITFLAG that describes the exit condition of FSOLVE. If EXITFLAG is: 0 then FSOLVE converged to a solution X. 0 then the maximum number of function evaluations was reached. 0 then FSOLVE did not converge to a solution.X,FVAL,EXITFLAG,OUTPUT=FSOLVE(FUN,X0,.) returns a structure OUTPUT with the number of iterations taken in OUTPUT.iterations, the number of function evaluations in OUTPUT.funcCount, the algorithm used in OUTPUT.algorithm, the number of CG iterations (if used) in OUTPUT.cgiterations, and the first-order optimality (if used) in OUTPUT.firstorderopt. X,FVAL,EXITFLAG,OUTPUT,JACOB=FSOLVE(FUN,X0,.) returns the Jacobian of FUN at X. Examples FUN can be specified using : x = fsolve(myfun,2 3 4, optimset(Display,iter) where MYFUN is a MATLAB function such as: function F = myfun(x) F = sin(x); FUN can also be an inline object: fun = inline(sin(3*x); x = fsolve(fun,1 4,optimset(Display,off);2 符号微分方程求解(Symbolic differential equation solution)符号微分方程求解函数:r=dsolve(eq1,eq2,cond1,cond2,v) 求由eq1,eq2,指定的微分方程的符号解,参数cond1,cond2,为指定常微分方程的边界条件或初始条件,自变量v如果不指定,将为默认自变量。方程中D表示一次微分D2和D3分别表示二次及三次微分,D后的字符为默认自变量。例1: 求微分方程dy/dx=ay的通解和当y(0)=b时的特解。dsolve(Dy=a*y)dsolve(Dy=a*y,y(0)=b,x)ans =C1*exp(a*t) 默认自变量为t ans =b*exp(a*x)例2: 求微分方程=-a2y当y=(0)=1及时的特解。dsolve(D2y=-a2*y,y(0)=1,Dy(pi/a)=0)ans =cos(a*t)五 符号数学的简易绘图函数(Easy ploting function of symbolic mathematics)1. 二维图绘图函数(Two dimensional plotting function)*ezplot(f) 绘制表达式f(x)的二维图形,轴坐标的近似范围为-2, 2.*ezplot(f,xmin,xmax) 绘制表达式f(x)的二维图形,轴坐标的近似范围为xmin, xmax.*ezpolar(f) 在极坐标下绘制函数表达式f(x)的二维图形。例1:绘制函数表达式x2-y2的二维图形syms x yezplot(x2-y4)例2:绘制误差函数f(x)=的二维图形. syms xezplot(erf(x)gridERF Error function.Y = ERF(X) is the error function for each element of X. X must be real. The error function is defined as: erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t2) dt.例3:在极坐标下绘制函数表达式1+cos(t)的二维图形。 syms tfigure (1) ezplot(1+cos(t)figure ( 2) ezpolar(1+cos(t)2. 三维绘图函数(Three dimensional plotting function)*ezplot3(x,y,z) 绘制由表达式x=x(t), y=y(t) 和z=z(t)定义的三维曲线,自变量t的变化范围为 -2, 2。*ezplot3(x,y,z,tmin, tmax) 绘制由表达式x=x(t), y=y(t) 和z=z(t)定义的三维曲线,自变量t的变化范围为 tmin, tmax。*ezplot3(,animate) 如果在函数中增加参数animate,则绘制三维动态轨迹图。例1:根据表达式x=sin(t), y=cos(t) 和 z=t, 绘制三维曲线. syms t; ezplot3(sin(t),cos(t),t, 0,6*pi) 例2:绘动态轨迹图syms t;ezplot3(sin(t),cos(t),t, 0,6*pi,animate)3 . 等高线绘图函数*ezcontour(f) 绘制由表达式f(x,y)定义的等高线,自变量 x和 y的变化范围为-2, 2。*ezcontour(f,domain) 绘制由表达式f(x,y)定义的等高线,自变量 x和 y的变化范围由domain确定,domain可以是41的矢量xmin,xmax,ymin,ymax,也可以是21的矢量min,max,当domain为的矢量时,minxmax,minymax。*eznotour(,n) 按nn的网格密度绘制等高线图,n的缺省值为60。例1:根据表达式f= 绘制f的等高线。syms x yf=3*(1-x)2*exp(-(x2)-(y+1)2)-10*(x/5-x3-y5) *exp(-x2-y2)-1/3*exp(-(x+1)2-y2);ezcontour(f,-3,3,49)例2:根据表达式绘制f=的填充等高线。syms x y f=3*(1-x)2*exp(-(x2)-(y+1)2)-10*(x/5-x3-y5) .*exp(-x2-y2)-1/3*exp(-(x+1)2-y2); ezcontourf(f,-3,3,49)CONTOURF Filled contour plot.CONTOURF(.) is the same as CONTOUR(.) except that the contoursare filled. Areas of the data at or above a given level are filled. Areas below a level are either left blank or are filled by a lower level. NaNs in the data leave holes in the filled contour plot.C = CONTOURF(.) returns contour matrix C as described in CONTOURC and used by CLABEL.C,H,CF = CONTOURF(.) also returns a column vector H of hand

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论