MATLAB习题及答案3_第1页
MATLAB习题及答案3_第2页
MATLAB习题及答案3_第3页
MATLAB习题及答案3_第4页
MATLAB习题及答案3_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

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

文档简介

1. 令,(1) 求和的点积(2) 求和的叉乘积(3) 求、的混和积参考答案: A=1,5,3; B=2,1,4; C=9,-1,5;(1) dot(A,B)ans = 19(2) cross(B,C)ans = 9 26 -11(3) dot(A,cross(B,C)ans = 1062. 令,。求解下列问题:(1)(2)(3)(4)(5)(6)(7)参考答案: A=2,-1;-2,-2; B=2,-3;0,-4; C=1;2; D=1,0;0,1;(1) 2*Aans = 4 -2 -4 -4(2) A+Bans = 4 -4 -2 -6(3) A*Bans = 4 -2 -4 14(4) A.*Bans = 4 3 0 8(5) B*Cans = -4 -8(6) A/Bans = 1.0000 -0.5000 -1.0000 1.2500(7) ABans = 0.6667 -0.3333 -0.6667 2.33333.求该矩阵的特征值和特征向量参考答案: X=9,8,8,9;2,7,4,7;6,4,6,1;4,0,7,4X = 9 8 8 9 2 7 4 7 6 4 6 1 4 0 7 4 V,D = eig(X)V = -0.7543 0.2437 + 0.1991i 0.2437 - 0.1991i -0.5547 -0.3821 0.2241 + 0.4505i 0.2241 - 0.4505i 0.5493 -0.4132 0.1132 - 0.5091i 0.1132 + 0.5091i 0.4280 -0.3382 -0.6131 -0.6131 -0.4554 D = 21.4707 0 0 0 0 1.1178 + 4.5139i 0 0 0 0 1.1178 - 4.5139i 0 0 0 0 2.2938 4. 生成 5 阶魔术矩阵,记为,对其进行如下操作(1)求的逆(2)计算的行列式(3)求的条件数(4)求矩阵的秩(5)求矩阵的迹参考答案: A=magic(5)A = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9(1) inv(A)ans = -0.0049 0.0512 -0.0354 0.0012 0.0034 0.0431 -0.0373 -0.0046 0.0127 0.0015 -0.0303 0.0031 0.0031 0.0031 0.0364 0.0047 -0.0065 0.0108 0.0435 -0.0370 0.0028 0.0050 0.0415 -0.0450 0.0111(2) det(A)ans = 5070000(3) cond(A)ans = 5.4618(4) rank(A)ans = 5(5) trace(A)ans = 655. ,对进行如下操作:(1) 求的 LU 分解(2) 求的正交分解(3) 求的特征值分解(4) 求的奇异值分解 X=9,0,1,2;9,3,2,1;4,8,1,0;8,0,6,7X = 9 0 1 2 9 3 2 1 4 8 1 0 8 0 6 7(1) L,U=lu(X)L = 1.0000 0 0 0 1.0000 0.3750 0.1549 1.0000 0.4444 1.0000 0 0 0.8889 0 1.0000 0U = 9.0000 0 1.0000 2.0000 0 8.0000 0.5556 -0.8889 0 0 5.1111 5.2222 0 0 0 -1.4755(2) Q,R=qr(X)Q = -0.5785 0.2866 0.5381 -0.5418 -0.5785 -0.1052 0.2182 0.7788 -0.2571 -0.9175 -0.0818 -0.2921 -0.5143 0.2548 -0.8100 -0.1206R = -15.5563 -3.7927 -5.0783 -5.3354 0 -7.6561 0.6871 2.2512 0 0 -3.9672 -4.3754 0 0 0 -1.1492(3) V,D = eig(X)V = 0.3650 -0.1238 - 0.1819i -0.1238 + 0.1819i -0.0337 0.4317 -0.2224 + 0.2205i -0.2224 - 0.2205i 0.2755 0.3764 -0.2020 + 0.5806i -0.2020 - 0.5806i -0.7751 0.7340 0.6897 0.6897 0.5676 D = 14.0539 0 0 0 0 3.8077 + 2.9407i 0 0 0 0 3.8077 - 2.9407i 0 0 0 0 -1.6693 (4) U,S,V = svd(X)U = -0.4891 -0.1120 -0.6156 -0.6077 -0.5268 0.2260 -0.3527 0.7396 -0.3136 0.8179 0.3860 -0.2893 -0.6204 -0.5171 0.5896 -0.0027S = 17.8325 0 0 0 0 8.3092 0 0 0 0 4.8357 0 0 0 0 0.7578V = -0.8614 0.0194 -0.5075 0.0109 -0.2293 0.8691 0.4198 -0.1262 -0.3128 -0.2341 0.5382 0.7468 -0.3279 -0.4354 0.5259 -0.65296. 比较稀疏矩阵与满矩阵的异同之处,如 eye(10) 与 speye(10) 生成矩阵的异同之处略。7. 将 10 阶随机矩阵转换为稀疏矩阵参考答案: A = rand(10) sparse(A)8. 将 10 阶稀疏正态随机矩阵转换为满矩阵参考答案: A = sprand(10,10,0.2) B = full(A)9. 计算下列积分(1)(2)(3)(4)(5)参考答案:(1) f = (x)x+x.3+x.5; q = quad(f,-1,1)q = 2.2204e-016(2) f2 = (x)sin(x)+cos(x); q = quad(f2,-1,10)q = 1.6768(3) f3=(x)exp(x/2) ; q = quad(f3,2,6)q = 34.7345(4) f4 = (x)x./(x.4+4); q = quad(f4,1,10)q =0.2718(5) f5 = (x,y)sin(y).*(x+y)./(x.2+4); q = dblquad(f5,1,10,1,10)q = 5.525410. 求下列函数的极值(1)(2)参考答案:(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. Current function value: -359212266339440800000000000000000000000000000000000000000000000000000000000000000000.000000 x = 1.0e+041 * 0.9523 -6.0686fvalue =-3.5921e+083flag = 0output = 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.5425 0.4575fvalue = 2.4109e-011flag = 1output = iterations: 40 funcCount: 74 algorithm: Nelder-Mead simplex direct search message: 1x196 char11. 求下列函数的解,并绘制图形(1),初始点为(2)参考答案:(1) 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 = 012. 有如下数据:x11.11.21.31.4y1.000001.233681.552711.993722.61170利用本章介绍的几种插值方法对其进行插值,得到每隔 0.05 的结果参考答案:编写脚本文件,文件内容为:% Interpolation using the four methodsx=1 1.1 1.2 1.3 1.4;y=1.00000 1.23368 1.55271 1.99372 2.61170;length_of_x=length(x);scalar_x=x(1):0.05:x(length_of_x);length_of_sx=length(scalar_x);y_nearest = zeros(length(scalar_x),1);y_linear = zeros(length(scalar_x),1);y_spline = zeros(length(scalar_x),1);y_cubic = zeros(length(scalar_x),1);for i=1:length_of_sx y_nearest(i)=interp1(x,y,scalar_x(i),nearest); y_linear(i) =interp1(x,y,scalar_x(i),linear); y_spline(i) =interp1(x,y,scalar_x(i),spline); y_cubic(i) =interp1(x,y,scalar_x(i),cubic);endsubplot(2,2,1),plot(x,y,*),hold on,plot(scalar_x,y_nearest),title(method=nearest);subplot(2,2,2)

温馨提示

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

评论

0/150

提交评论