您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > MATLAB教程-R2014a-答案-全-张志涌
目录第一章.................................................................................................................................1第二章.................................................................................................................................5第三章...............................................................................................................................12第四章...............................................................................................................................32第五章...............................................................................................................................47第六章...............................................................................................................................54补充题欧拉法,龙格库塔法解方程,黑板上的题.....................................................57第一章1.创建表达式%可以用syms先符号运算再带入值x=1;y=2;z=(sqrt(4*x^2+1)+0.5457*exp(-0.75*x^2-3.75*y^2-1.5*x))/(2*sin(3*y)-1)z=-1.43452.计算复数x=(-1+sqrt(-5))/4;y=x+8+10jy=7.7500+10.5590i3.help命令学三维曲线x=-5:0.1:5;y=x;[X,Y]=meshgrid(x,y);Z=(sin(sqrt(X.^2+Y.^2)))./(sqrt(X.^2+Y.^2));subplot(221);surf(X,Y,Z);colormap(cool);subplot(222);plot3(X,Y,Z,'linewidth',4);%绘制三维曲线,也可以随意给定一个三维曲线的函数。如果画这个曲面,那么将绘出一族三维曲线gridon;subplot(223);meshz(X,Y,Z);%地毯绘图subplot(224);meshc(X,Y,Z);%等高线绘图4.peaks等高线(更改原函数)subplot(221);contour(peaks1,20);subplot(222);contour3(peaks1,10);%可以定义等高线条数subplot(223);contourf(peaks1,10);subplot(224);peaks1;z=3*(1-x).^2.*exp(-(x.^2)-(y+1).^2)...-10*(x/5-x.^3-y.^5).*exp(-x.^2-y.^2)...-1/3*exp(-(x+1).^2-y.^2)5.LOGO绘制membranelogo第一章书后习题1.合法性不合法合法不合法不合法合法2.运行命令及探讨a=sqrt(2)a=1.4142答:不是精确的2。是一个近似。可通过改变format进行位数显示调整。例如:formatlong;a=sqrt(2)formatshort;a=1.414213562373095或可使用digits任意指定输出位数。例如:digits(50);a=sqrt(2);vpa(a)ans=1.4142135623730950488016887242096980785696718753769常见情况下毋需太高精度。3.运行结果讨论formatlong;w1=a^(2/3)w2=a^2^(1/3)w3=(a^(1/3))^2w1=1.259921049894873w2=1.259921049894873w3=1.259921049894873测试结果为相同,说明MATLAB程序执行时经过的过程相同。4.clearclfclcclear为从内存中清除变量和函数clf为清除figure中的已绘图形以及子图形clc为清除命令行窗口5.产生二维数组显然第一第二个方法可以实现。例如:s=[123;456;789]s=123456789即是一个简便的键入矩阵的方法。第二章1数据类型class(3/7+0.1)class(sym(3/7+0.1))class(vpa(sym(3/7+0.1),4))class(vpa(sym(3/7+0.1)))ans=doubleans=symans=symans=sym2哪些精准?a1=sin(sym(pi/4)+exp(sym(0.7)+sym(pi/3)));a2=sin(sym(pi/4)+exp(sym(0.7))*exp(sym(pi/3)));a3=sin(sym('pi/4')+exp(sym('0.7'))*exp(sym('pi/3')));a4=sin(sym('pi/4')+exp(sym('0.7+pi/3')));a5=sin(sym(pi/4)+exp(sym(0.7+pi/3)));a6=sin(sym(pi/4)+sym(exp(0.7+pi/3)));a7=sin(sym(pi/4+exp(0.7+pi/3)));a8=sym(sin(pi/4+exp(0.7+pi/3)));digits(64);vpa(a2-a1)vpa(a3-a1)vpa(a4-a1)%为精确值vpa(a5-a1)vpa(a6-a1)vpa(a7-a1)vpa(a8-a1)ans=8.772689107613377606024459313047548287536202098197290121158158175e-72ans=8.772689107613377606024459313047548287536202098197290121158158175e-72ans=0.0ans=-0.0000000000000008874822716959584619522637254014249128254875650208152937300697045ans=-0.000000000000001489122128176563341755713716272780778030227615022223735634526288ans=-0.000000000000001518855593927822635897082947744411794950714383466168364259064934ans=-0.00000000000000151859755909122793880734918235619076228065004813152159311456667可以看到,除了a4为精确,其余均存在很小的误差。其中a2与a3的误差较小,小于eps精度,故可认为为精确的。3独立自由变量a1=sym('sin(w*t)');a2=sym('a*exp(-X)');a3=sym('z*exp(j*th)');symvar(a1,1)symvar(a2,1)symvar(a3,1)ans=wans=aans=z6符号解symsxk;f1=x.^k;s1=symsum(f1,k,0,inf);s2=subs(f1,x,(-1/3));s3=subs(f1,x,(1/pi));s4=subs(f1,x,3);symsum(s2,k,0,inf)double(symsum(s3,k,0,inf))symsum(s4,k,0,inf)ans=3/4ans=1.4669ans=Inf7限定性假设reset(symengine);symsk;symsxpositive;f1=(2/(2*k+1))*((x-1)/(x+1))^(2*k+1);f1_s=symsum(f1,k,0,inf);simplify(f1_s,'steps',27,'IgnoreAnalyticConstraints',true)ans=log(x)8符号计算symst;yt=abs(sin(t));dydt=diff(yt,t)dydt0=limit(dydt,t,0,'left')dydtpi=subs(dydt,t,(pi/2))dydt=sign(sin(t))*cos(t)dydt0=-1dydtpi=09积分值symsx;fx=exp(-abs(x))*abs(sin(x))fxint=int(fx,-5*pi,1.7*pi);vpa(fxint,64)fx=abs(sin(x))*exp(-x)ans=3617514.63564708870710001839346550055424273505783512343177368070410二重积分symsxy;fxy=x^2+y^2;int(int(fxy,y,1,x^2),x,1,2)ans=1006/10511绘出曲线symstx;fx=int((sin(t)./t),t,0,x);ezplot(fx)fx4=subs(fx,x,4.5)fx4=sinint(9/2)-6-4-20246-2-1.5-1-0.500.511.52xsinint(x)12积分表达式symsx;symsnpositive;yn=int((sin(x)).^n,x,0,pi/2)yn3=subs(yn,n,1/3);vpa(yn3,32)yn=beta(1/2,n/2+1/2)/2ans=1.293554779614895267476757512565613序列卷积symsabn;symskpositive;xk=a.^k;hk=b.^k;kn=subs(xk,k,k-n)*subs(hk,k,n);yk=symsum(kn,n,0,k)yk=piecewise([a==bandb~=0,b^k*(k+1)],[a~=borb==0,(a*a^k-b*b^k)/(a-b)])所以答案为a*a^k-b*b^k)/(a-b)20求解solvereset(symengine)symsxy;s=solve('x^2+y^2-1','x*y-2','x','y')s.xs.ys=x:[4x1sym]y:[4x1sym]ans=((15^(1/2)*i)/2+1/2)^(1/2)/2-((15^(1/2)*i)/2+1/2)^(3/2)/2-((15^(1/2)*i)/2+1/2)^(1/2)/2+((15^(1/2)*i)/2+1/2)^(3/2)/2(1/2-(15^(1/2)*i)/2)^(1/2)/2-(1/2-(15^(1/2)*i)/2)^(3/2)/2-(1/2-(15^(1/2)*i)/2)^(1/2)/2+(1/2-(15^(1/2)*i)/2)^(3/2)/2ans=((15^(1/2)*i)/2+1/2)^(1/2)-((15^(1/2)*i)/2+1/2)^(1/2)(1/2-(15^(1/2)*i)/2)^(1/2)-(1/2-(15^(1/2)*i)/2)^(1/2)23求通解clearall;yso=simplify(dsolve('Dy*y*0.1+0.3*x=0','x'))yso=(-
本文标题:MATLAB教程-R2014a-答案-全-张志涌
链接地址:https://www.777doc.com/doc-3810742 .html