中南大学matlab课后习题(七).pdf





《中南大学matlab课后习题(七).pdf》由会员分享,可在线阅读,更多相关《中南大学matlab课后习题(七).pdf(40页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、第一章思考练习1.与一般的Windows程 序样,启动MATLAB系统有3种常见方法:(1)使用Windows“开始”菜单。(2)运 行MATLAB系统启动程序matlab.exe。(3)利用快捷方式。要退出MATLAB系统,也有3种常见方法:(2)在MATLAB命令窗口输入Exit或Quit命令。(3)单 击MATLAB主窗口的“关闭”按钮。2.matlab用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境,主要包括MATLAB和Simulink两大部分。它将数值分析、矩阵计算、科学数据可视化以及非线性动态系统的建模和仿真等诸多强大功能集成在一个易于使用的视窗环境中
2、,为科学研究、工程设计以及必须进行有效数值计算的众多科学领域提供了一种全面的解决方案3.可以在第一个物理行之后加上三个小黑点并按回车键,然后再下一个物理行输入其他部分。4.help命令会显示当前帮助系统中的所有项目,即搜索路径中所有的目录名称,只显示那些与关键字中完全匹配的结果。Lookfor命令对搜索范围内的M文件经行搜索,条件比较宽泛。第二章(1)w=sqrt(2)*(1+0.34245*10A(-6)(2)a=3.5b=5c=9.8x=(2*pi*a+(b+c)/(pi+a*b*c)exp(2)/(tan(b+c)+a)(3)a=3.32b=7.9y=2*pi*aA2*(1-pi/4)*
3、b-(0.8333-pi/4)*a)(4)t=2,l-3i;5,-0.65JZ=0.5*exp(2*t)*log(t+sqrt(l+t.*t)2.A=-1,5,-4;0,7,8;3z 61,7;B=8,3,T;2,5,3;-3,2,0;(1)A+6*B AA2-B+eye(2)A*B A.*B B.*A(3)A/B BA(4)A,B A(1A3 ,:);B-23.(1)A=23,10,-0.778,0;41,-45,65,5;32,5,0,32;6,-9.54,54,3.14;K=find(A10&A25);A(K)(2)A=23,10,-0.778,0;41,-45,65,5;32,5,0,
4、32;6,-9.54,54,3.14;B=A(1:3,:)C=A(:z1:2)D=A(2:4Z3:4)E=B*C(3)E=90&score=80&score=70&score=60&score=69;disp(D);elseif score=0;disp(*E);elsedisp(,出错,);End(2)用 switch语句score=input(请 输 入 成 绩:;switch fix(score/10)case 9,10disp(*A);case 8disp(*B);case 7disp(e);case 6disp(*D);case 0,1,2,3,4,5disp(lE);otherwi
5、sedisp(1 出错,);End3.b=max(a)c=min(a)b=0c=0f o r i=l:20if a(i)bb=a(i);e n dif a(i)5n=5A(n,n)e ls eA(n)7.f l.m 代码:f u n c t io n m=f 1(n)m=n+10*lo g(r T 2+5);f 2.m 代码:f u n c t io n m=f 2(n)m=0;f o r i=l:nm=m+i*(i+l);e n d在命令文件p3L m中调用f l.m和f 2.mp3_ ll.m代码如下:y l=f 1(40)/(f l(30)+f 1(20);y 2二 f 2(40)/(f
6、 2(30)+f 2(20);y ly 21008.Z 4 函数文件f ac t o r l.m代码如下:k=f u n c t io n f=f ac t o r l(k)if k=lf=l;e ls ef=f ac t o r 1(k-1)+k;e n d50Z%八 2 函数文件f ac t o r 2.m代码:k=f u n c t io n f=f ac t o r 2(k)if k=lf=l;e ls ef=f ac t o r 2(k-D+2;e n d10函数文件f ac t o r 3.m代码:k=f u n c t io n f=f ac t o r 3(k)if k=lf=
7、l;e ls ef=f ac t o r 3(k-l)+l/k;e n d思考练习2.N=1,2,3,4,5A=N.*2B=N./4C=l./ND=1./(N./2)./(N./2)/43.B=0f o r i=l:20A(i)=f ix(99-10+1)*r an d(1)+10);B=A +B;e n dB=B/20f o r i=l:20if A(i)B&r e m(A(i),2)=0A(i)e n d第四章.1.(l).x=-12:0.001:12;y=x-x.-3/6;plo t (x,y);x labe l(x 轴);y labe l(y 轴);t it le,Y=X X 3/3!
8、);(2)t=0:0.01:2*pi;x=8.*cos(t);y=4*sqrt(2).*sin(t);plot(x,y)2.t=-pi:pi/10:pi;y=l./(l+exp(-t);subplot(2,2,1);bar(tz y,b!);title(bar(t,yz 1 1b*),);axis(-5,5,-3z 3);subplot(2,2,2);stairs(t,y,*k*);title(stairs(t,yz 1 1k )1);axis(-5,5,-3Z 3);subplot(2,2,3);stem(tz y,m*);title(stem(tz y,*m1 1);axis(-5,5,-
9、3f 3);subplot(2,2,4);loglog(tAy,*g*);title(*loglog(t,yz 1*g*);axis(5,5,-3,3);3.(1)t=0:pi/100:2*pi;y=5*cos(t)+4;polarity;-*)(2)t=-pi/3:pi/100:pi/3;r=5*sin(t).A2./cos(t);polarftj;-*)4.(l)t=0:pi/100:2*pi;x=exp(-t/20).*cos(t);y=exp(-t/20).*sin(t);z=t;plot3(x,y,z)(2)x,y=meshgrid(-5:5);z=ones(ll);s u r f(
10、x,y,z);s hadin g in t e r p;5.x,y,z =s phe r e (50);m=mo v ie in(100);f o r i=l:100s u r f(i*x,i*y,i*z);s hadin g in t e r pc o lo r map(ho t);ax is e qu alax is (-100,100,-100,100,-100,100)ax is o f fm(:,i)=ge t f r ame;E n d思考练习2.(1)x=l:0.1:10a=e x p(x.*2)/2)y=a.*l/2/piplo t (x,y)(2)t=-pi:0.l:2*pi
11、X=t.*s in(t)Y=t.*c o s(t)plo t (X,Y)3.t=0:0.00005:pi;x=s in(3*t).*c o s(t);y l=2*x-0.5;y 2=s in(3*t).*s in(t);plo t (x,y 2,x,y l);ho ld o nk=f in d(abs(y 2-y l)le-4);x l=x(k);y 3=2*x l-0.5;plo t (x l,y 3,r p)4.x=-pi*6:0.l:pi*6y=s in(l./x)plo t (x,y)f plo t C s in(l./x)f,-pi*6,pi*6,le-4)5.(1)x=l:0.1:
12、10y=12./xpo lar (x,y)(2)x=-pi/6:0.l:pi/6y=3*s in(x).*c o s(x)./(s in(x).3+c o s(x).3)po lar (x,y)6.(1)u,v =me s hgr id(-pi:pi/100:pi);x=3*u.*s in(v);y=2*u.*c o s(v);z=4*u.*u;me s h(x,y,z);(2)x,y =me s hgr id(-3:6/100:3);z=-5./(1+x.*x+y.*y);me s h(x,y,z)第五章1.A=randn(10,5)(1)X=mean(A)Y=std(A,O4)(2)max
13、(max(A)min (min (A)(3)B=sum(A,2)s u m(4)sort(A);sort(A,2/descend)2.(1)t=0:15:90;xl=0,0.2588,0.5000,0.7071,0.8660,0.9659,1.0000;al=0:l:90;yl=interpl(t,xl,al,spline)x 2=0,0.2679,0.5774,1.0000,1.7320,3.7320,N aN ;a2=0:1:75;y2=interpl(t,x2/a2/spline)pl=po ly f it (t,x l,5);Z l=po ly v al(pl,al)p2=po ly
14、f it(t,x 2,5);z 2=po ly v al(p2,a2)(2)X=l 4 9 16 25 36 49 64 81 100J;Y=l:10;Xl=l:100;Yl=interpl(X,Y,Xl;cubic,)3.4.P=2,-3,5,13;Q=l,5,8;p=po ly de r(P)pl=po ly de r(P,Q)p,q=po ly de r (P,Q)5.P 1=1,2,4,0,5;P 2=l,0;P 3=l,2,3;l)P 4=c o n v(P 2,P 3)P 4=0,1,2,3,0;P=P 1+P 42)x=r o o t s(P)3)A=-1,1.2,-1.4;0,
15、75,2,3,5;0,5,2.5;Y=po ly v al(P,A)4)Z=po ly v alm(P,A)第六章1.(1)A=l/2,l/3,l/4;l/3,1/4,l/5;l/4,l/5,l/6;B=0.95,0.67,0.52*;x=AB(2)A=l/2,1/3,l/4;l/3,1/4,l/5;l/4,l/5,l/6;B=0.95,0.67,0.53,;x=AB(3)cond(A)2.(1)建立函数文件fim x.m,命令如下;Function fx=funx(x)fx=xA41+xA3+l;调用fzero函数求根,命令如下;z=fzero(funx,-l)(2)建立函数文件sin.m,
16、命令如下;Function fx=sin(x)fx=x(sin(x)/x;调用fzero函数求根,命令如下;z=fzero(sin,0.5)(3)建立函数文件myfun.m,命令如下;f u n c t io n q=my f u n(p)x=p(l);y=p(2);z=p ;q(l)=s in (x)+y x=sym(,x,);f=exp(x)*(exp(x)+1 )A2;int(f,0,log(2)ans=(exp(6243314768165359/9007199254740992)*(3*exp(6243314768165359/9007199254740992)+exp(6243314
17、768165359/4503599627370496)+3)/3-7/34 x=sym(,x,);f=x*log(x);int(f,l,exp(l)ans=(9366741398929500034245406117369*log(3060513257434037/1125899906842624)/25353012004564588029934064107528099090798701270632748702911993/50706024009129176059868128215045 求级数和1 syms n;s=symsum(-1 )An+1 )/n,1 ,inf)Inf2 syms n;
18、s=symsum(xA2*n-l/2*n-1,1,inf)s=Inf*n-Inf*(n/2+1)6 求泰勒展开式1 syms x;fl=(exp(x)+exp(-x)/2;taylor(f 1,5,0)In sym.taylor at 97ans=xA4/24+xA2/2+12 syms x;fl=sqrt(xA3-2*x+1);taylor(f 1,6,0)Warning:The syntax of TAYLOR has changed.The old syntax is partially supported in thisrelease,butwill be removed in a f
19、uture release.Second argument must be a variable.See doc taylor fordetails.In sym.taylor at 97ans=-xA5/8-xA4/8-xA2/2-x+17 求非线性方程的符号解1 syms x y z a;x=solve(,xA3+ax+1 =0,x)x=(-ax-1)八(1/3)(3A(l/2)*i)/2-1/2)*(-ax-l)A(l/3)-(3A(l/2)*i)/2+l/2)*(-ax-l)A(l/3)2 syms x y z a;solve(,sinx4-2*cosx-sqrt(x),x,)ans=
20、(2*cosx+sinx)八 22x y=solve(log(x/y)=9,exp(x+y)=3,x,y)x=(exp(9)*log(3)/(exp(9)+1)y=log/(exp +1)8求微分方程初值syms x y z a n;x y=dsolve(x*D2y+(1 -n)*Dy+y=0/Dy(0)=y(0)=0,x,)Warning:Explicit solution could not be found.In dsolve at 194x=empty sym y=J思考练习i符号运算可以自动合并同类项及化简数值运算不含未知数2 x=sym(,x,);y=2*(cos(x)A2-(si
21、n(x)A2y=2*cos(x)A2-sin(x)A2 simple(y)simplify:2-3*sin(x)A2radsimp:2*cos(x)A2-sin(x)A2simplify(lOO):3*cos(x)A2-1combine(sincos):(3*cos(2*x)/2+1/2combine(sinhcosh):2*cos(x)A2-sin(x)A2combine(ln):2*cos(x)A2-sin(x)A2factor:2*cos(x)A2-sin(x)A2expand:2*cos(x)A2-sin(x)A2combine:2*cos(x)A2-sin(x)A2rewrite(e
22、xp):2*(exp(-x*i)/2+exp(x*i)/2)A2-(exp(-x*i)*i)/2-(exp(x*i)*i)/2)A2rewrite(sincos):2*cos(x)A2-sin(x)A2rewrite(sinhcosh):2*cosh(x*i)A2+sinh(x*i)八 2rewrite(tan):(2*(tan(x/2)A2-l)A2)/(tan(x/2)A2+1)A2-(4*tan(x/2)A2)/(tan(x/2)A2+1)A2mwcos2sin:2-3*sin(x)A2collect(x):2*cos(x)A2-sin(x)A2ans=2-3*sin(x)A22 sym
23、s x y s=sin(x)*cos(y)-cos(x)*sin(y);simple(s)simplify:sin(x-y)radsimp:cos(y)*sin(x)-cos(x)*sin(y)simplify(lOO):sin(x-y)combine(sincos):sin(x-y)combine(sinhcosh):cos(y)*sin(x)-cos(x)*sin(y)combine(ln):cos(y)*sin(x)-cos(x)*sin(y)factor:-(cos(x)*sin(y)-cos(y)*sin(x)expand:cos(y)*sin(x)-cos(x)*sin(y)com
24、bine:cos(y)*sin(x)-cos(x)*sin(y)rewrite(exp):(exp(-x*i)/2+exp(x*i)/2)*(exp(-y*i)*i)/2-(exp(y*i)*i)/2)+(exp(-x*i)*i)/2(exp(x*i)*i)/2)*(exp(-y*i)/2+exp(y*i)/2)rewrite(sincos):cos(y)*sin(x)-cos(x)*sin(y)rewrite(sinhcosh):cosh(x*i)*sinh(y*i)*i-cosh(y*i)*sinh(x*i)*irewrite(tan):(2*tan(y/2)*(tan(x/2)A2-l)
25、/(tan(x/2)A2+l)*(tan(y/2)A2+1)-(2*tan(x/2)*(tan(y/2)A2-l)/(tan(x/2)A2+l)*(tan(y/2)A2+1)mwcos2sin:sin(y)*(2*sin(x/2)A2-1)-sin(x)*(2*sin(y/2)A2-1)collect(x):cos(y)*sin(x)-cos(x)*sin(y)ans=sin(x-y)3 syms a b s=sqrt(a+sqrt(aA2-b)/2)+sqrt(a-sqrt(aA2-b)/2);simple(s)simplify:2A(l/2)*(a+(aA2-b)A(l/2)A(l/2)/
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 中南 大学 matlab 课后 习题

限制150内