实验2 MATLAB的符号运算

更新时间:2023-10-11 03:39:02 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

实验2 MATLAB的符号运算

1、 演示:几种输入下产生矩阵的异同。 A1= [1/3,0.2+sqrt(2),pi] >> A1=[1/3 0.2+sqrt(2) pi]

A1 =

0.3333 1.6142 3.1416 A2=sym([1/3,0.2+sqrt(2),pi]) >> A2=sym(A1) A2 =

[ 1/3, 7269771597999872*2^(-52), A3=sym(‘[1/3,0.2+sqrt(2),pi]’) >> A3=sym('[1/3 0.2+sqrt(2) pi]') A3 =

[ 1/3, 0.2+sqrt(2), pi]

2、 用符号计算验证三角等式sin?1cos?2?cos?1sin?2?sin(?1??2)。(sym或syms,simple) > syms a1 a2

>> simple(sin(a1)*cos(a2)-cos(a1)*sin(a2)) ans =

sin(a1-a2) 3、 求矩阵A???a11a12??a21a?的行列式、逆和特征根。(syms,det,inv,eig) 22?>> syms a11 a12 a21 a22

>> A=[a11 a12;a21 a22]; >> Q1=det(A) Q1 =

a11*a22-a12*a21 >> Q2=inv(A) Q2 =

[ a22/(a11*a22-a12*a21), -a12/(a11*a22-a12*a21)] [ -a21/(a11*a22-a12*a21), a11/(a11*a22-a12*a21)] >> [M,L]=eig(A) M =

pi] [ -(1/2*a22-1/2*a11-1/2*(a22^2-2*a11*a22+a11^2+4*a12*a21)^(1/2))/a21, -(1/2*a22-1/2*a11+1/2*(a22^2-2*a11*a22+a11^2+4*a12*a21)^(1/2))/a21]

[ 1, 1] L = [ 1/2*a22+1/2*a11+1/2*(a22^2-2*a11*a22+a11^2+4*a12*a21)^(1/2), 0]

[ 0, 1/2*a22+1/2*a11-1/2*(a22^2-2*a11*a22+a11^2+4*a12*a21)^(1/2)]

t3?d?ad24、 求:?? ,tdx?tcosxlnx?dt>> syms a t x

>> A=[a t^3;t*cos(x) log(x)]; >> Q1=diff(A,'x') Q1 =

[ 0, 0] [ -t*sin(x), 1/x]

>> Q2=diff(diff(A,'t'),'t') Q2 =

[ 0, 6*t] [ 0, 0]

>> Q3=diff(diff(A,'x'),'t') Q3 =

[ 0, 0] [ -sin(x), 0]

?at3?d2??和dxdt?tcosxlnx??at3?(syms,diff) ??。

?tcosxlnx?w?sin?/2?iwt2Aedt?A??5、 验证积分???/2w?2>> syms A w t a >> f=A*exp(-i*w*t); >> Q=int(f,'t',-a/2,a/2)

(syms,int,simple)

Q =

i*A*(exp(-1/2*i*w*a)-exp(1/2*i*w*a))/w

>> r=simple(Q) r =

2*A*sin(1/2*w*a)/w

6、 用符号变量求解联立方程:y?3x2?3x?5;y??5x?2的解。(syms,solve) >> g1='y=3*x^2+3*x+5';g2='y=-5*x-2'; >> [x,y]=solve(g1,g2) x =

[ -4/3-1/3*i*5^(1/2)] [ -4/3+1/3*i*5^(1/2)] y =

[ 14/3+5/3*i*5^(1/2)] [ 14/3-5/3*i*5^(1/2)]

7、 用符号变量求解微分方程:

dfdg?3f?4g,??4f?3g,f(0)?0,g(0)?1的解析dxdx解。(dsolve)

>> [f,g]=dsolve('Df=3*f+4*g','Dg=-4*f+3*g','f(0)=0','g(0)=1') f =

exp(3*t)*sin(4*t) g =

exp(3*t)*cos(4*t)

8、 求下列级数的和:I?21??1(syms,symsum) ???nn?23?n?1??>> syms n

>> I=2*symsum(1/2^n+1/3^n,1,inf) I = 3

9、 计算时域函数f(t)的拉氏变换,其中f(t)?(syms,laplace,simple) >> syms t

>> f=(2*exp(-3*t)+3*sin(2*t)-2*cos(2*t))/13;

1(2e?3t?3sin2t?2cos2t)。13>> q=laplace(f) q =

2/13/(s+3)+6/13/(s^2+4)-2/13*s/(s^2+4) >> simple(q) ans =

2/(s+3)/(s^2+4)

本文来源:https://www.bwwdw.com/article/vnkf.html

Top