77范文网 - 专业文章范例文档资料分享平台

第四章 MATLAB的数值计算功能(2)(2)

来源:网络收集 时间:2019-04-09 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

c=conv(a,b) %乘法运算

cs=poly2sym(c,’s’) %建立指定变量为s的符号形式多项式 c =

4 13 28 27 18 cs =

4*s^4+13*s^3+28*s^2+27*s+18

例2: 展开(s2+2s+2)(s+4)(s+1) (多个多项式相乘) c=conv([1,2,2],conv([1,4],[1,1]))

cs=poly2sym(c,’s’) %(指定变量为s) c =

1 7 16 18 8 cs =

s^4+7*s^3+16*s^2+18*s+8

例3:求多项式s^4+7*s^3+16*s^2+18*s+8分别被(s+4),(s+3)除后的结果。

c=[1 7 16 18 8];

[q1,r1]=deconv(c,[1,4]) %q—商矢量, r—余数矢量 [q2,r2]=deconv(c,[1,3])

cc=conv(q2,[1,3]) %对除(s+3)结果检验 test=((c-r2)==cc) q1 =

1 3 4 2 r1 =

0 0 0 0 0 q2 =

1 4 4 6 r2 =

0 0 0 0 -10 cc =

1 7 16 18 18

test =

1 1 1 1 1

3. 其他常用的多项式运算命令(Other computation command of polynomial)

pa=polyval(p,s) 按数组运算规则计算给定s时多项式p的值。 pm=polyvalm(p,s) 按矩阵运算规则计算给定s时多项式p的值。 [r,p,k]=residue(b,a) 部分分式展开,b,a分别是分子(numerator)分

母(denominator)多项式系数矢量,r,p,k分别是留数、极点和直项矢量

p=polyfit(x,y,n) 用n阶多项式拟合x,y矢量给定的数据。 polyder(p) 多项式微分。 注: 对于多项式b(s)与不重根的n阶多项式a(s)之比,其部分分式展开为:

b(s)rrr?1?2?L?n?k(s) a(s)s?p1s?p2s?pn

式中:p1,p2,…,pn称为极点(poles),r1,r2,…,rn 称为留数(residues),k(s)称为直项(direct terms),假如a(s)含有m重根pj,则相应部分应写成:

rjs?pj?rj?1(s?pj)2?L?rj?m?1(s?pj)m

RESIDUE Partial-fraction expansion (residues).

[R,P,K] = RESIDUE(B,A) finds 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 polynomials in descending powers of s. The residues

are 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

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))^m

[B,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.

例1:对 (3x4+2x3+5x2+4x+6)/(x5+3x4+4x3+2x2+7x+2) 做部分分式展开

a=[1 3 4 2 7 2]; b=[3 2 5 4 6]; [r,s,k]=residue(b,a) r =

1.1274 + 1.1513i 1.1274 - 1.1513i -0.0232 - 0.0722i -0.0232 + 0.0722i 0.7916 s =

-1.7680 + 1.2673i -1.7680 - 1.2673i 0.4176 + 1.1130i 0.4176 - 1.1130i -0.2991 k =

[] (分母阶数高于分子阶数时,k将是空矩阵,表示无此项)

例2:对一组实验数据进行多项式最小二乘拟合(least square fit)

x=[1 2 3 4 5]; % 实验数据 y=[5.5 43.1 128 290.7 498.4];

p=polyfit(x,y,3) %做三阶多项式拟合 x2=1:.1:5; %加密

y2=polyval(p,x2); % 根据给定值计算多项式结果 plot(x,y,’o’,x2,y2)

二、线性代数(Linear Algebra)

解线性方程(Linear equation)就是找出是否存在一个唯一的矩阵x,使得a,b满足关系:

ax=b 或 xa=b

MALAB中左除x=a\\b 是方程式 ax=b 的解,右除b/a是方程式xa=b的解。

通常线性方程多写成ax=b,“\\”较多用,左、右除两者的关系为:

(b/a)’=(a’\\b’)

系数矩阵a可能是m行n列的,有三种情况:

*方阵系统: (Square matrix) m=n 可求出精确解(a必须是非奇异 (nonsingular),即满秩(full rank)。 *超定系统:(Overdetermind system) m>n 可求出最小二乘解

*欠定系统:(Underdetermind system) m

MATLAB对不同形式的参数矩阵,采用不同的运算法则来处理,它会自动检测参数矩阵,以区别下面几种形式: *三角矩阵(Triangular Matrix)

*对称正定矩阵(symmetrical positive determined matrix) *非奇异方阵(Nonsingular matrix) *超定系统(Overdetermind system) *欠定系统(Underdetermind system)

1. 方阵系统:(Square array) m=n

最常见的方程式为ax=b形式,系数矩阵a为方阵,常数项b为列矢

量, 其解x可写成x=a\\b, x和b大小相同。 例1: 用左除求方阵系统的根。 a=[11 6 7; 5 13 9; 17 1 8] b=[16 13 4]’ x=a\\b a =

11 6 7 5 13 9 17 1 8 b = 16 13 4 x =

3.9763 5.4455 -8.6303

例2:假如a,b为两个大小相同的矩阵,可用左除求方阵系统的根。a=[4 5 9; 18 19 5; 1 4 13]

b=[1 5 12; 3 15 19; 7 6 10] x=a\\b C=a*x a =

4 5 9 18 19 5 1 4 13 b =

1 5 12

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库第四章 MATLAB的数值计算功能(2)(2)在线全文阅读。

第四章 MATLAB的数值计算功能(2)(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/582115.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: