資源描述:
《《MATLAB符號運算》PPT課件》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、MATLAB語言程序設(shè)計Timethestudypainistemporary,hasnotlearnedthepainislife-long.第八講MATLAB符號運算1設(shè)置符號變量2微分積分運算3方程求解4線性代數(shù)運算5其它命令21.設(shè)置符號變量1.設(shè)置符號變量x=sym('x')symsarg1arg2...32.微分積分運算1.微分diff(S,'v')(s對變量v求偏導(dǎo))diff(S,n)(對s求n次導(dǎo))diff(S,'v',n)(s對變量v求n次偏導(dǎo))42.微分積分運算2.積分R=i
2、nt(S)R=int(S,v)R=int(S,a,b)R=int(S,v,a,b)52.微分積分運算int(exp(-x^2),0,inf)ans=1/2*pi^(1/2)int([exp(t),exp(alpha*t)])ans=[exp(t),1/alpha*exp(alpha*t)]62.微分積分運算int(x/(1+z^2),z)ans=atan(z)*xint(2*x,sin(t),1)ans=1-sin(t)^272.微分積分運算3.極限limit(F,x,a)limit(F,a)(
3、x->a時F的極限)limit(F)(x->0時F的極限)limit(F,x,a,'right')limit(F,x,a,'left')82.微分積分運算例如:symsxath;limit(sin(x)/x)=>1limit(1/x,x,0,'right')=>inflimit(1/x,x,0,'left')=>-inflimit((sin(x+h)-sin(x))/h,h,0)=>cos(x)92.微分積分運算4.級數(shù)和symsum(s,t,a,b)s中t從a到b求和。>>symsum(x^2
4、,x,1,'n')ans=1/3*(n+1)^3-1/2*(n+1)^2+1/6*n+1/6103.方程求解1.代數(shù)方程(solve)g=solve(eq)g=solve(eq,var)g=solve(eq1,eq2,...,eqn)g=solve(eq1,eq2,...,eqn,var1,var2,...,varn)113.方程求解如:solve('a*x^2+b*x+c')ans=[1/2/a*(-b+(b^2-4*a*c)^(1/2)),1/2/a*(-b-(b^2-4*a*c)^(1/2
5、))]solve('a*x^2+b*x+c','b')ans=-(a*x^2+c)/xsolve('x+y=1','x-11*y=5')y=-1/3,x=4/3123.方程求解A=solve('a*u^2+v^2','u-v=1','a^2-5*a+6')A=a:[1x4sym]u:[1x4sym]v:[1x4sym]這里A.a=[2,2,3,3]133.方程求解A.u=[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*
6、i*3^(1/2)]A.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)]143.方程求解2.微分方程(dsolve)r=dsolve('eq1,eq2,...','cond1,cond2,...','v')r=dsolve('eq1','eq2',...,'cond1','cond2',...,'v')例如:dsolve('Dy=a*y')ans=exp(a*t)*C1153.方程求解d
7、solve('Df=f+sin(t)')ans=-1/2*cos(t)-1/2*sin(t)+exp(t)*C1dsolve('(Dy)^2+y^2=1','s')ans=-sin(-s+C1)dsolve('Dy=a*y','y(0)=b')ans=exp(a*t)*b163.方程求解dsolve('D2y=-a^2*y','y(0)=1','Dy(pi/a)=0')ans=cos(a*t)dsolve('Dx=y','Dy=-x')x=cos(t)*C1+sin(t)*C2y=-sin(t)
8、*C1+cos(t)*C2174.線性代數(shù)運算matlab中大多數(shù)用于數(shù)值線性代數(shù)計算的命令,都可以用于符號變量線性代數(shù)的運算。>>symsxt>>A=[sin(t)x^2;9t*x]>>det(A)>>inv(A)>>eig(A)185.其它命令因式分解(factor)factor(X)例如:factor(x^3-y^3)ans=(x-y)*(x^2+x*y+y^2)195.其它命令factor([a^2-b^2,a^3+b^3])ans=[(a-b)*(a+b),(a+b)*(a^2-a*b