1、P(x)=a0xn+a1xn-1+a2xn-2an-1x+an则其系数矢量(Vector of coefficient)为:P=a0 a1 an-1 an如将根矢量(Vector of root)表示为:ar= ar1 ar2 arn则根矢量与系数矢量之间关系为:(x-ar1)(x- ar2) (x- arn)= a0xn+a1xn-1+a2xn-2an-1x+an(2)多项式的创建(polynomial creating) a)系数矢量的直接输入法利用poly2sym函数直接输入多项式的系数矢量,就可方便的建立符号形式的多项式。 例1:创建多项式x3-4x2+3x+2poly2sym(1 -
2、4 3 2)ans =x3-4*x2+3*x+2POLY Convert roots to polynomial. POLY(A), when A is an N by N matrix, is a row vector with N+1 elements which are the coefficients of the characteristic polynomial, DET(lambda*EYE(SIZE(A) - A) .POLY(V), when V is a vector, is a vector whose elements are the coefficients of t
3、he polynomial whose roots are the elements of V . For vectors, ROOTS and POLY are inverse functions of each other, up to ordering, scaling, and roundoff error.b) 由根矢量创建多项式已知根矢量ar, 通过调用函数 p=poly(ar)产生多项式的系数矢量, 再利用poly2sym函数就可方便的建立符号形式的多项式。例2:由根矢量创建多项式。将多项式(x-6)(x-3)(x-8)表示为系数形式的多项式。 a=6 3 8 %根矢量pa=po
4、ly(a) %求系数矢量ppa=poly2sym(pa) %以符号形式表示原多项式ezplot(ppa,-50,50)pa = 1 -17 90 -144ppa =x3-17*x2+90*x-144说明:(1)根矢量元素为n ,则多项式系数矢量元素为n+1; (2)函数poly2sym(pa) 把多项式系数矢量表达成符号形式的多项式,缺省情况下自变量符号为x,可以指定自变量。 (3)使用简单绘图函数ezplot可以直接绘制符号形式多项式的曲线。例 3: 由给定复数根矢量求多项式系数矢量。r=-0.5 -0.3+0.4i -0.3-0.4i;p=poly(r)pr=real(p)ppr=poly
5、2sym(pr)p = 1.0000 1.1000 0.5500 0.1250pr =ppr =x3+11/10*x2+11/20*x+1/8含复数根的根矢量所创建的多项式要注意: (1)要形成实系数多项式,根矢量中的复数根必须共轭成对; (2)含复数根的根矢量所创建的多项式系数矢量中,可能带有很小的虚部,此时可采用取实部的命令(real)把虚部滤掉。如果需要进行系数表示形式的多项式的求根运算,有两种方法可以实现,一是直接调用求根函数roots,poly和 roots 互为逆函数。另一种是先把多项式转化为伴随矩阵,然后再求其特征值,该特征值即是多项式的根。c) 特征多项式输入法用poly函数还
6、可实现由矩阵的特征多项式系数创建多项式。条件:特征多项式系数矢量的第一个元素必须为一。例 2: 求三阶方阵A的特征多项式系数,并转换为多项式形式。a=6 3 8;7 5 6; 1 3 5Pa=poly(a) %求矩阵的特征多项式系数矢量Ppa=poly2sym(pa)Pa = 1.0000 -16.0000 38.0000 -83.0000Ppa =注:n 阶方阵的特征多项式系数矢量一定是n +1阶的。例 4: 将多项式的系数表示形式转换为根表现形式。求 x3-6x2-72x-27的根a=1 -6 -72 -27r=roots(a)r = 12.1229 -5.7345 -0.3884MATL
7、AB约定,多项式系数矢量用行矢量表示,根矢量用列矢量表示。2. 多项式的乘除运算(Multiplication and division of polynomial)向量的卷积与解卷积对应着多项式的乘除法,多项式乘法(卷积)用函数conv(a,b)实现, 除法(解卷积)用函数deconv(a,b)实现。长度为m的向量a和长度为n的向量b的卷积定义为:C(k)=C向量的长度为:m+n-1解卷积是卷积的逆运算是向量a对向量c进行解卷积将得到商向量 q和余量r,并且满足:例1:a(s)=s2+2s+3, b(s)=4s2+5s+6,计算 a(s)与 b(s)的乘积。a=1 2 3; b=4 5 6;
8、 %建立系数矢量c=conv(a,b) cs=poly2sym(c,s) %建立指定变量为s的符号形式多项式c = 4 13 28 27 18cs =4*s4+13*s3+28*s2+27*s+18 展开(s2+2s+2)(s+4)(s+1) (多个多项式相乘)c=conv(1,2,2,conv(1,4,1,1)cs=poly2sym(c,s) %(指定变量为s) 1 7 16 18 8s4+7*s3+16*s2+18*s+8求多项式s4+7*s3+16*s2+18*s+8分别被(s+4),(s+3)除后的结果。c=1 7 16 18 8;q1,r1=deconv(c,1,4) %q商矢量,
9、r余数矢量q2,r2=deconv(c,1,3)cc=conv(q2,1,3) %对除(s+3)结果检验test=(c-r2)=cc)q1 = 1 3 4 2r1 = 0 0 0 0 0q2 = 1 4 4 6r2 = 0 0 0 0 -10cc = 1 7 16 18 18test = 1 1 1 1 13. 其他常用的多项式运算命令(Other computation command of polynomial)pa=polyval(p,s) 按数组运算规则计算给定s时多项式p的值。pm=polyvalm(p,s) 按矩阵运算规则计算给定s时多项式p的值。r,p,k=residue(b,a
10、) 部分分式展开,b,a分别是分子分母多项式系数矢量,r,p,k分别是留数、极点和直项矢量p=polyfit(x,y,n) 用n阶多项式拟合x,y矢量给定的数据。polyder(p) 多项式微分。 对于多项式b(s)与不重根的n阶多项式a(s)之比,其部分分式展开为:式中:p1,p2,pn称为极点(poles),r1,r2,rn 称为留数(residues),k(s)称为直项(direct terms),假如a(s)含有m重根pj,则相应部分应写成:RESIDUE Partial-fraction expansion (residues). R,P,K = RESIDUE(B,A) finds
11、 the residues, poles and direct term of a partial fraction expansion of the ratio of two polynomials B(s)/A(s). If there are no multiple roots,B(s) R(1) R(2) R(n) - = - + - + . + - + K(s) A(s) s - P(1) s - P(2) s - P(n)Vectors B and A specify the coefficients of the numerator and denominator polynom
12、ials in descending powers of s. The residuesare returned in the column vector R, the pole locations in column vector P, and the direct terms in row vector K. The number of poles is n = length(A)-1 = length(R) = length(P). The direct term coefficient vector is empty if length(B) length(A), otherwise
13、length(K) = length(B)-length(A)+1.If P(j) = . = P(j+m-1) is a pole of multplicity m, then the expansion includes terms of the form R(j) R(j+1) R(j+m-1)- + - + . + - s - P(j) (s - P(j)2 (s - P(j)mB,A = RESIDUE(R,P,K), with 3 input arguments and 2 output arguments, converts the partial fraction expansion back to the polynomials with coefficients in B and A.例3:对 (3x4+2x3+5x2+4x+6)/(x5+3x4+4x3+2x
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1