MATLAB基础教程 薛山 课后答案2-12章.pdf_第1页
MATLAB基础教程 薛山 课后答案2-12章.pdf_第2页
MATLAB基础教程 薛山 课后答案2-12章.pdf_第3页
MATLAB基础教程 薛山 课后答案2-12章.pdf_第4页
MATLAB基础教程 薛山 课后答案2-12章.pdf_第5页
已阅读5页,还剩31页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

2 1double (1) a=87b=190a+ba- ba*b (2)uint8(1) 1 a=87 a = 87 b=190 b = 190 a+b ans = 277 a- b ans = - 103 a*b ans = 16530 2 c=uint8(87) c = 87 d=uint8(190) d = 190 c+d ans = 255 c- d ans = 0 c*d ans = 255 2 (1)sin 60 (2) e3 (3) 3 cos 4 1 sind(60) ans = 0.8660 2 exp(3) ans = 20.0855 3 cos(3*pi/4) ans = - 0.7071 32u3v (1) 4 log uv v (2) 2 2 euv vu (3) 3uv uv 1 u=2; v=3; 4*u*v/log(v) ans = 21.8457 2 (exp(u)+v)2/(v2- u) ans = 15.4189 3 sqrt(u- 3*v)/(u*v) ans = 0 + 0.4410i 4 (1)3 542ii (2)sin 28i 1 (3- 5*i)*(4+2*i) ans = 22.0000 - 14.0000i 2 sin(2- 8*i) ans = 1.3553e+003 +6.2026e+002i 5 (1) 4 4 4 4=20 ans = 0 4 4=20 ans = 1 5 b a=39; b=58; c=3; d=7; ab ans = 0 2 a ab disp(sind(60); disp(exp(3)=); disp(exp(3); disp(cos(3*pi/4)=); disp(cos(3*pi/4); 86 a=39; b=58; c=3; d=7; disp(ab),disp(ab); disp(ac),disp(a|bc); disp(d),disp(d); 3 1. x = 9 3 0 6 3 y = mod(sqrt(length(x+5).*1 2 3 4 5)*5),3) y y =2 2.MATLAB a = 3, 7, 2, 7, 9, 3, 4, 1, 6; b = 7; a(4) = ; vec1 = a=b; vec2 = mod(a,2)=0; c = sum(vec1); vec3 = vec1+vec2; d = vec3.*a; vec4 = find(a 5); e = a(vec4) + 5; vec5 = find(a y=(x)exp(x)- x5; x = fzero(y,8) x = 12.7132 fplot(y,x- 1,x+1); hold on plot(x,y(x),r*); 2 y=(x)x*sin(x); x = 0 3. (1) 2 2 1zxy (2) 2 1zxy 1 z = (x)x(1)2- (x(2)- 1)2; x,fvalue,flag,output=fminsearch(z,0,0) Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. Currentfunctionvalue: - 35921226633944080000000000000000000000000000000000000000000000000000000000 0000000000.000000 x = 1.0e+041 * 0.9523- 6.0686 fvalue = - 3.5921e+083 flag = 0 output = iterations: 200 funcCount: 401 algorithm: Nelder- Mead simplex direct search message: 1x233 char 2 z = (x)(x(1)- x(2)+1)2; x,fvalue,flag,output=fminsearch(z,0,0) x = - 0.54250.4575 fvalue = 2.4109e- 011 flag = 1 output = iterations: 40 funcCount: 74 algorithm: Nelder- Mead simplex direct search message: 1x196 char implex direct searchimplex direct search message: 1x233 char z = (x)(x(1)- x(2)+1)2; z = (x)(x(1)- x(2)+1)2; x,fvalue,flag,output=fminsearch(z,0,0) x,fvalue,flag,output=fminsearch(z,0,0) 4. (1) 1 35 1 dxxxx (2) 1010 2 11 sind d 4 xy yx y x 1 f = (x)x+x.3+x.5; q = quad(f,- 1,1) q = 2.2204e- 016 (2) f5 = (x,y)sin(y).*(x+y)./(x.2+4); q = dblquad(f5,1,10,1,10) q = 5.5254 5 1 % find the times and places of the specified letter in the string letter = a;% The specified letter to be searched for string = China;% The specified tring to be searched places = findstr(S,A); % The places of the letter ntimes = length(places);% The times of the letter 2 str = this is the string to be converted; nlength = length(str); for k=1:nlength if (k=1 | isspace(str(k-1) end end disp(str); 32212 double cellA = cell(2,2); cellA(1,1) = the first element of the cell; cellA(1,2) = the second element of the cell; cellA(2,1) = uint8(5); cellA(2,2) = 2,3;3,4; 4 structtest=struct(name,number,scores,) (k=1 | isspace(str(k-1) str(k) = char(double(str(k) - 32); (k=1 | isspace(str(k-1) cellA(1,1) = the first element of the cell; cellA(1,2) = the second element of the cell; cellA(1,2) = the second element of the cell; cellA(2,1) = uint8(5); 6 1.x = - 3, 0, 0, 2, 5, 8y = - 5, - 2,0, 3, 4, 10 MATLAB 1z = ydigits(1) vpa(subs(f,x,pi/6) ans = 1. digits(2) vpa(subs(f,x,pi/6) ans = 1.0 digits(5) vpa(subs(f,x,pi/6) ans = 1.0236 digits(10) vpa(subs(f,x,pi/6) ans = 1.023598776 3x 42 1f xxx 32 458g xxxx 1f xg x 2f xg x 3g x 4gf x f = sym(x4 + x2 + 1); g = sym(x3 + 4*x2 + 5*x + 8); 1 f+g ans = f xxxf xxx 4242 f xxx 42424242 f xxxf xxxf xxx 424242 x4+5*x2+9+x3+5*x 2 f*g ans = (x4+x2+1)*(x3+4*x2+5*x+8) 3 finverse(g) Warning: finverse(x3 + 4*x2 + 5*x + 8) is not unique. In sym.finverse at 43 ans = 1/6*(- 656+108*x+12*(2988- 984*x+81*x2)(1/2)(1/3)+2/3/(- 656+108*x+12*(2988- 984*x+81*x2)(1/2)(1/3)- 4/3 4 syms x compose(g,f,x) ans = (x4+x2+1)3+4*(x4+x2+1)2+5*x4+5*x2+13 4 1 22 325325xxxx 3 222 2322521xxyyxyxxyyxy 1 f = sym(3*x -2*x2 + 5 + 3*x2 -2*x - 5); collect(f) ans = x+x2 2 f = sym(2*x2 -3*x*y + y2 -2*x*y -2*x2 + 5*x*y -2*y + 1); collect(f) ans = y2- 2*y+1 5 17798666 2 8 - 2m +512 3 2322 3a (x- y) - 4b (y- x) xyyxyxxyyxyyxyxxyy23225212322521 (x4+x2+1)3+4*(x4+x2+1)2+5*x4+5*x2+13(x4+x2+1)3+4*(x4+x2+1)2+5*x4+5*x2+13 325325325325325325325325325325325325325325325325325325325325 222222222222222 23225212322521 222222222 23225212322521232252123225212322521xyyxyxxyyxyyxyxxyy232252123225212322521232252123225212322521232252123225212322521 f = sym(3*x -2*x2 + 5 + 3*x2 -2*x - 5); f = sym(3*x -2*x2 + 5 + 3*x2 -2*x - 5); 1 factor(sym(779866) ans = (2)*(149)*(2617) 2 factor(sym(- 2*m8 + 512) ans = - 2*(m- 2)*(m+2)*(m2+4)*(m4+16) 3 factor(sym(3*a2*(x- y)3 -4*b2*(y- x)2) ans = (x- y)2*(3*a2*x- 4*b2- 3*a2*y) 6 1 2 sinf xxx0,2 2 32 21f xxx2,2 1 f = sym(sin(x) + x2); ezplot(f,0,2*pi); 2 f = sym(x3 + 2*x2 + 1); ezplot(f,- 2 2); 7 1 0 tansin lim 1 cos2 x xx x 2 32 2sinyxxxy 3lnyxyxy/fx/fy 2 /fx y 4ln(1)yt dx 27 0 ln(1)yt dx 1 limit(sym(tan(x) -sin(x)/(1- cos(2*x) ans = 0 2 f = sym(sin(x) + x2); f = sym(sin(x) + x2); f = sym(x3 + 2*x2 + 1); tansintansin 1 cos21 cos2 tansin x x x x tansin y = sym(x3 -2*x2 + sin(x); diff(y) ans = 3*x2- 4*x+cos(x) 3 f = x*y*log(x+y); fx = diff(f,x) fx = y*log(x+y)+x*y/(x+y) fy = diff(f,y) fy = x*log(x+y)+x*y/(x+y) f2xy = diff(fx,y) f2xy = log(x+y)+y/(x+y)+x/(x+y)- x*y/(x+y)2 4 syms t y = log(1+t); int(y) ans = log(1+t)*(1+t)- t- 1 int(y,0,27) ans = 56*log(2)+28*log(7)- 27 8 1 1 3 n n n 2 1 2 sin 3 n n n 3sin x0Taylor 1 symsum(sym(3/n)n),1,inf) ans = sum(3/n)n,n = 1 Inf) 2 symsum(sym(2n*sin(pi/(3n),1,inf) ans = 3(1/2) 3 taylor(sym(sin(x) ans = x- 1/6*x3+1/120*x5 9 231 321 xy xy x,y = solve(sym(2*x+3*y=1),sym(3*x+2*y=- 1) x = - 1 y = 1 10 22 xy zxe 1x 2y 3xyZ 1 syms x y z = x*exp(- (x2+y2); syms u v fourier(z,x,u) ans = - 1/2*i*pi(1/2)*u*exp(- y2- 1/4*u2) 2 laplace(z,y,v) ans = 1/2*x*exp(- x2)*pi(1/2)*exp(1/4*v2)*erfc(1/2*v) 3 ztrans(z,x,u) ans = - u*diff(ztrans(exp(- x2- y2),x,u),u) ztrans(z,y,v) ans = x*ztrans(exp(- x2- y2),y,v) 11 22 1 exp 2 f xxy33x33y syms x y z = x*exp(- (x2+y2); z = x*exp(- (x2+y2); exp(- y2- 1/4*u2)exp(- y2- 1/4*u2) laplace(z,y,v) z = 1/(2*pi)*exp(- (x2+y2); ezsurf(x,y,z,- 3,3,- 3,3); 8 1.0,2 /104 x=0:pi/10:2*pi; sinx = sin(x); cosx = cos(x); figure,plot(x,sinx,LineWidth,4) hold on,plot(x,cosx,r:,LineWidth,4) hold on,plot(x(find(cosx=sinx),cosx(find(cosx=sinx),r*,LineWidth,4) 2 1sinyxx010x 2 22 6621zxxyyxy1010x1010y 3 22 164 xy z1616x44y 1 x = 0:pi/10:10*pi; plot(x,sin(x) 2 X,Y = meshgrid(- 10:0.5:10); Z = X.2 + 6*X*Y + Y.2 + 6*X + 2*Y - 1; plot3(X,Y,Z) 3 X,Y = meshgrid(- 16:0.4:16,- 4:0.1:4); Z = X.2/16 -Y.2/4; plot3(X,Y,Z) 3. 1 2100010 310010 1pie 66216621zxxyyxy66216621662166216621 16161616161616161616161616161616161616161616 10101010101010101010 4444y y444444444444 X,Y = meshgrid(- 10:0.5:10); X,Y = meshgrid(- 10:0.5:10); Z = X.2 + 6*X*Y + Y.2 + 6*X + 2*Y - 1; Z = X.2 + 6*X*Y + Y.2 + 6*X + 2*Y - 1; 2 hist(round(rand(100,1)*10) 3 X = round(rand(10,1)*10); stairs(X) 4.1 title(); gtext(sin(x) gtext(cos(x) legend(sin(x),cos(x) 5.2 viewcolormap 9 1 lnfx010x figure,title(),plot(0:0.2:10, log(0:0.2:10) 2 4 22 22 1 xy ab ab figure(Color,y); set(gca,DefaultLineLineWidth,4); a = 4; b = 3; x = linspace(-a,a,100); y1 = sqrt(1-x.2/(a2)*b2); y2 = -sqrt(1-x.2/(a2)*b2); plot(x,y1); hold on; plot(x,y2); 3MATLAB cos 2sin 2 t x t t y t 22t t = -2:0.1:2; x = cos(t/pi); y = 2*sin(t/(2*pi); figure,plot(t,x); hold on; plot(t,y); %if waitforbuttonpress while(1) if waitforbuttonpress=0 get(gcf,CurrentObject); c = ceil(rand) * 5); switch c case 1 2222t t222222222222 set(get(gcf,CurrentObject),Color, r); case 2 set(get(gcf,CurrentObject),Color, g); case 3 set(get(gcf,CurrentObject),Color, b); case 4 set(get(gcf,CurrentObject),Color, k); case 5 set(get(gcf,CurrentObject),Color, y); end end end 10 1MATLABGUI 2GUI 3callbackfunction 4GUIGUI 5GUI 2 yaxbxcabca 11 1.SimulinkCommonly used Blocks 2. 2 1 1223 2 213 123 4 210 8 xxxx x xxx xxx 123 0xxx Simulink 1 x 2 x 3 x 1 x 2 x

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论