资源预览内容
第1页 / 共16页
第2页 / 共16页
第3页 / 共16页
第4页 / 共16页
第5页 / 共16页
第6页 / 共16页
第7页 / 共16页
第8页 / 共16页
第9页 / 共16页
第10页 / 共16页
亲,该文档总共16页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
Matlab实验报告实验2 数值数组及运算一、 实验目的(1) 掌握一维数组、二维数组、多项式和高维数组的创建(2) 掌握对数组操作的常用函数二、 实验内容使用冒号运算符创建下面各表达式对应的向量。 x=logspace(1,3,3); x=10.1:3x = 10 100 1000 x=logspace(1,3,5)x = 1.0e+003 * 0.0100 0.0316 0.1000 0.3162 1.0000利用MATLAB内置函数计算下面的值 cosh(5)ans = 74.2099 sinh(-2)ans = -3.6269 (exp(5)+exp(-5)/2ans = 74.2099 help erf ERF Error function. Y = ERF(X) is the error function for each element of X. X must be real. The error function is defined as: erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t2) dt. Class support for input X: float: double, single See also erfc, erfcx, erfinv. Overloaded functions or methods (ones with the same name in other directories) help sym/erf.m Reference page in Help browser doc erf erf(1.2)ans = 0.9103利用linspace函数创建下面表达式的对应向量 x=0:10; x=linspace(0,10,11)x = 0 1 2 3 4 5 6 7 8 9 10 x=0:0.2:10; x=linspace(0,10,51)x = Columns 1 through 16 0 0.2000 0.4000 0.6000 0.8000 1.0000 1.2000 1.4000 1.6000 1.8000 2.0000 2.2000 2.4000 2.6000 2.8000 3.0000 Columns 17 through 32 3.2000 3.4000 3.6000 3.8000 4.0000 4.2000 4.4000 4.6000 4.8000 5.0000 5.2000 5.4000 5.6000 5.8000 6.0000 6.2000 Columns 33 through 48 6.4000 6.6000 6.8000 7.0000 7.2000 7.4000 7.6000 7.8000 8.0000 8.2000 8.4000 8.6000 8.8000 9.0000 9.2000 9.4000 Columns 49 through 51 9.6000 9.8000 10.0000 x=-12:12; x=linspace(-12,12,25)x = -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 x=10:-1:1; x=linspace(10,1,10)x = 10 9 8 7 6 5 4 3 2 1 x=10 9 8 7x = 10 9 8 7 x=10 9 8 7;y=1 2 3 4; z=x-y; zz = 9 7 5 3计算 A=1 2 3 3;2 3 5 7;1 3 5 7;3 2 3 9;1 8 9 4; B=1+4i 4 3 6 7;2 3 3 5 5;2 6+7i 5 3 4;1 8 9 4 3; C=A*B; CC = 1.0e+002 * 0.1400 + 0.0400i 0.5200 + 0.2100i 0.5100 0.3700 0.3800 0.2500 + 0.0800i 1.0300 + 0.3500i 1.0300 0.7000 0.7000 0.2400 + 0.0400i 0.9900 + 0.3500i 1.0000 0.6400 0.6300 0.2200 + 0.1200i 1.0800 + 0.2100i 1.1100 0.7300 0.7000 0.3900 + 0.0400i 1.1400 + 0.6300i 1.0800 0.8900 0.9500 D=C(4:5,3:5); DD = 111 73 70 108 89 95 A=1 2 3 3;2 3 5 7;1 3 5 7;3 2 3 9;1 8 9 4; A=1 2 3 3;2 3 5 7;1 3 5 7;3 2 3 9;1 8 9 4A = 1 2 3 3 2 3 5 7 1 3 5 7 3 2 3 9 1 8 9 4 A=4 12 20;12 45 78;20 78 136; B=1 2 3;4 5 6;7 8 0; I=1 0 0;0 1 0;0 0 1; A+5*Bans = 9 22 35 32 70 108 55 118 136 A-B+Ians = 4 10 17 8 41 72 13 70 137 A.*Bans = 4 24 60 48 225 468 140 624 0 A*Bans = 192 228 84 738 873 306 1284 1518 528 A.Bans = 1.0e+015 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0002 0.0000 1.3701 0.0000 ABWarning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.328379e-018.ans = 1.0e+015 * 0.0000 -0.0000 3.6192 -0.0000 0.0000 -7.2384 0.0000 -0.0000 3.6192 A/Bans = 9.3333 -1.3333 0.0000 40.0000 -7.0000 0.0000 70.6667 -12.6667 0.0000 A(find(A50)&(A B(find(B5)ans = 7 8 6 A=1 2 NaN Inf -Inf 5 NaNA = 1 2 NaN Inf -Inf 5 NaN isnan(A)ans = 0 0 1 0 0 0 1 isfinite(A)ans = 1 1 0 0 0 1 0 isinf(A)ans = 0 0 0 1 1 0 0 any(A)ans = 1 all(A)ans = 1求出以下矩阵的逆矩阵 A=1 -5 -2;3 4 -9;-7 2 6A = 1 -5 -2 3 4 -9 -7 2 6 B=sin(1) sin(-5) sin(-2);sin(3) sin(4) sin(9); sin(-7) sin(2) sin(6)B = 0.8415 0.9589 -0.9093 0.1411 -0.7568 0.4121 -0.6570 0.9093 -0.2794 inv(A)ans = -0.1673 -0.1036 -0.2112 -0.1793
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号