MATLAB第二章实验报告.doc

上传人:飞****2 文档编号:51831073 上传时间:2022-10-20 格式:DOC 页数:14 大小:74.50KB
返回 下载 相关 举报
MATLAB第二章实验报告.doc_第1页
第1页 / 共14页
MATLAB第二章实验报告.doc_第2页
第2页 / 共14页
点击查看更多>>
资源描述

《MATLAB第二章实验报告.doc》由会员分享,可在线阅读,更多相关《MATLAB第二章实验报告.doc(14页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、 MATLAB数据及基本操作班级:11电信一班姓名:何得中学号:实验目的:1. 熟悉MATLAB的组体成体系及工作环境;2. 了解MATLAB的帮助系统;3. 掌握MATLAB的数据类型及变量的基本操作;4. 掌握矩阵建立的基本方法及其运算;5. 掌握矩阵索引与分析方法;6. 熟悉字符串单元及结构数据的建立及基本操作。实验仪器:MATLAB软件,电脑实验数据: A=1 2 3;4 5 6;7 8 9A = 1 2 3 4 5 6 7 8 9 A=1 2 3 4 5 6 7 8 9A = 1 2 3 4 5 6 7 8 9 x=0:pi/8:2*pi; y=cos(x)y = Columns 1

2、 through 10 1.0000 0.9239 0.7071 0.3827 0.0000 -0.3827 -0.7071 -0.9239 -1.0000 -0.9239 Columns 11 through 17 -0.7071 -0.3827 -0.0000 0.3827 0.7071 0.9239 1.0000 B=ones(3,5)B = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 zeros(3)ans = 0 0 0 0 0 0 0 0 0 C=rand(3,4)C = 0.9501 0.4860 0.4565 0.4447 0.2311 0.8913 0.018

3、5 0.6154 0.6068 0.7621 0.8214 0.7919 D=randn(2,3)D = -0.4326 0.1253 -1.1465 -1.6656 0.2877 1.1909 eye(3)ans = 1 0 0 0 1 0 0 0 1 M=magic(4)M = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 T=toeplitz(1:5,1:6)T = 1 2 3 4 5 6 2 1 2 3 4 5 3 2 1 2 3 4 4 3 2 1 2 3 5 4 3 2 1 2 H=hilb(5)H = 1.0000 0.5000 0.3333 0.

4、2500 0.2000 0.5000 0.3333 0.2500 0.2000 0.1667 0.3333 0.2500 0.2000 0.1667 0.1429 0.2500 0.2000 0.1667 0.1429 0.1250 0.2000 0.1667 0.1429 0.1250 0.1111 a=3:18a =3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 b=1:0.2:6b =Columns 1 through 9 1.0000 1.2000 1.4000 1.600 1.8000 2.0000 2.2000 2.4000 2.6000 Colu

5、mns 10 through 18 2.8000 3.0000 3.2000 3.4000 3.6000 3.8000 4.0000 4.2000 4.4000 Columns 19 through 26 4.6000 4.8000 5.0000 5.2000 5.4000 5.6000 5.8000 6.0000 linspace(1,15,10)ans =Columns 1 through 9 1.0000 2.5556 4.1111 5.6667 7.2222 8.7778 10.3333 11.8889 13.4444Column 10 15.0000 y=0.9 0.3 0.4 0.

6、1 0.5 0.6 0.2 ; sorted,index=sort(y)sorted =0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.9000index =4 7 2 3 5 6 1 A=rand(4,5)A = 0.9218 0.9355 0.0579 0.1389 0.2722 0.7382 0.9169 0.3529 0.2028 0.1988 0.1763 0.4103 0.8132 0.1987 0.0153 0.4057 0.8936 0.0099 0.6038 0.7468 a,b=min(A)a =0.1763 0.4103 0.009

7、9 0.1389 0.0153b = 3 3 4 1 3 min(A(:)ans = 0.0099 V=1 2 3 4V = 1 2 3 4 norm(V,2)ans =5.4772 norm(V,1)ans = 10 norm(V,inf)ans = 4 V=2 5 6 8 4 9V = 2 5 6 8 4 9 min(V)ans = 2 V=4 9 6;7 8 9;4 5 6V = 4 9 6 7 8 9 4 5 6 min(V)ans = 4 5 6 max(V)ans = 7 9 9 mean(V)ans = 5.0000 7.3333 7.0000 median(V)ans = 4

8、8 6 std(V)ans = 1.7321 2.0817 1.7321 diff(V)ans =3 -1 3 -3 -3 -3 sort(V)ans =4 5 6 4 8 6 7 9 9 length(V)ans = 3 norm(V)ans =19.9125 sum(V)ans = 15 22 21 prod(V)ans =112 360 324 cumsum(V)ans = 4 9 6 11 17 15 15 22 21 cumprod(V)ans = 4 9 6 28 72 54 112 360 324 V=1 2 8V = 1 2 8 U=3; 4;7U = 3 4 7 dot(V,

9、U)ans =67 cross(V,U)ans =-18 17 -2 A=5 6 4;7 8 9;4 5 6A = 5 6 4 7 8 9 4 5 6 B=6 2 7 ;7 5 8;4 6 8B = 6 2 7 7 5 8 4 6 8 C=A-BC = -1 4 -3 0 3 1 0 -1 -2 C=A*BC = 88 64 115 134 108 185 83 69 116 C1=ABC1 =0.6667 -6.4444 -7.6667 0.6667 4.8889 7.3333 -0.3333 1.2222 0.3333 C2=B/AC2 = -3.0000 8.3333 -9.3333 -

10、1.6667 5.5556 -5.8889 0.0000 -1.3333 3.3333 A=1 2 3;4 5 6;7 8 9A = 1 2 3 4 5 6 7 8 9 D=A2D = 30 36 42 66 81 96 102 126 150 E=A0.1E = 0.8466 + 0.2270i 0.3599 + 0.0579i -0.0967 - 0.1015i 0.4015 + 0.0216i 0.4525 + 0.0133i 0.4432 - 0.0146i -0.0134 - 0.1740i 0.4848 - 0.0509i 1.0132 + 0.0820i A=1+2*i 3;4

11、2+iA =1.0000 + 2.0000i 3.0000 4.0000 2.0000 + 1.0000i Aans = 1.0000 - 2.0000i 4.0000 3.0000 2.0000 - 1.0000i A=1 2 3;4 5 6;7 8 9A = 1 2 3 4 5 6 7 8 9 B=3 4 6;7 9 8;5 2 01B = 3 4 6 7 9 8 5 2 1 C=A.*BC = 3 8 18 28 45 48 35 16 9 D=A./BD = 0.3333 0.5000 0.5000 0.5714 0.5556 0.7500 1.4000 4.0000 9.0000 E

12、=A.BE = 3.0000 2.0000 2.0000 1.7500 1.8000 1.3333 0.7143 0.2500 0.1111 A=1+2*i 3;4 2+iA = 1.0000 + 2.0000i 3.0000 4.0000 2.0000 + 1.0000i A.2ans = -3.0000 + 4.0000i 9.0000 16.0000 3.0000 + 4.0000i A.ans = 1.0000 + 2.0000i 4.0000 3.0000 2.0000 + 1.0000i x=0.1:0.1:0.8x =0.1000 0.2000 0.3000 0.4000 0.5

13、000 0.6000 0.7000 0.8000 y=sin(2*x).*cos(2*x)y =0.1947 0.3587 0.4660 0.4998 0.4546 0.3377 0.1675 -0.0292 y=sin(x)y =0.0998 0.1987 0.2955 0.3894 0.4794 0.5646 0.6442 0.7174 y=cos(x)y =0.9950 0.9801 0.9553 0.9211 0.8776 0.8253 0.7648 0.6967 y=tan(x)y =0.1003 0.2027 0.3093 0.4228 0.5463 0.6841 0.8423 1

14、.0296 y=cot(x)y =9.9666 4.9332 3.2327 2.3652 1.8305 1.4617 1.1872 0.9712 y=sec(x)y = 1.0050 1.0203 1.0468 1.0857 1.1395 1.2116 1.3075 1.4353 y=csc(x)y = 10.0167 5.0335 3.3839 2.5679 2.0858 1.7710 1.5523 1.3940 y=asin(x)y = 0.1002 0.2014 0.3047 0.4115 0.5236 0.6435 0.7754 0.9273 y=acos(x)y = 1.4706 1

15、.3694 1.2661 1.1593 1.0472 0.9273 0.7954 0.6435 y=atan(x)y =0.0997 0.1974 0.2915 0.3805 0.4636 0.5404 0.6107 0.6747 y=acot(x)y = 1.4711 1.3734 1.2793 1.1903 1.1071 1.0304 0.9601 0.8961 y=asec(x)y =Columns 1 through 6 0 + 2.9932i 0 + 2.2924i 0 + 1.8738i 0 + 1.5668i 0 + 1.3170i 0 + 1.0986i Columns 7 t

16、hrough 8 0 + 0.8956i 0 + 0.6931i y=sinh(x)y =0.1002 0.2013 0.3045 0.4108 0.5211 0.6367 0.7586 0.8881 y=cosh(x)y =1.0050 1.0201 1.0453 1.0811 1.1276 1.1855 1.2552 1.3374 y=tanh(x)y = 0.0997 0.1974 0.2913 0.3799 0.4621 0.5370 0.6044 0.6640 y=coth(x)y = 10.0333 5.0665 3.4327 2.6319 2.1640 1.8620 1.6546

17、 1.5059 y=sech(x)y = 0.9950 0.9803 0.9566 0.9250 0.8868 0.8436 0.7967 0.7477 y=csch(x)y = 9.9834 4.9668 3.2839 2.4346 1.9190 1.5707 1.3182 1.1260 y=asinh(x)y = 0.0998 0.1987 0.2957 0.3900 0.4812 0.5688 0.6527 0.7327 y=acosh(x)y =Columns 1 through 6 0 + 1.4706i 0 + 1.3694i 0 + 1.2661i 0 + 1.1593i 0 +

18、 1.0472i 0 + 0.9273i Columns 7 through 8 0 + 0.7954i 0 + 0.6435i y=atanh(x)y = 0.1003 0.2027 0.3095 0.4236 0.5493 0.6931 0.8673 1.0986 y=acoth(x)y = Columns 1 through 6 0.1003 + 1.5708i 0.2027 + 1.5708i 0.3095 + 1.5708i 0.4236 + 1.5708i 0.5493 + 1.5708i 0.6931 + 1.5708i Columns 7 through 8 0.8673 +

19、1.5708i 1.0986 + 1.5708i y=asech(x)y = 2.9932 2.2924 1.8738 1.5668 1.3170 1.0986 0.8956 0.6931 y=acsch(x)y = 2.9982 2.3124 1.9189 1.6472 1.4436 1.2838 1.1545 1.0476 y=log(x)y =-2.3026 -1.6094 -1.2040 -0.9163 -0.6931 -0.5108 -0.3567 -0.2231 y=log10(x)y = -1.0000 -0.6990 -0.5229 -0.3979 -0.3010 -0.221

20、8 -0.1549 -0.0969 y=log2(x)y =-3.3219 -2.3219 -1.7370 -1.3219 -1.0000 -0.7370 -0.5146 -0.3219 c=complex(a,b)c = 0.1763 + 3.0000i 0.4103 + 3.0000i 0.0099 + 4.0000i 0.1389 + 1.0000i 0.0153 + 3.0000i zc=conj(x)zc =0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 b=imag(x)b = 0 0 0 0 0 0 0 0 a=re

21、al(x)a = 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 y=fix(x)y = 0 0 0 0 0 0 0 0 y=floor(x)y =0 0 0 0 0 0 0 0 y=ceil(x)y = 1 1 1 1 1 1 1 1 y=round(x)y = 0 0 0 0 1 1 1 1 y=sign(x)y = 1 1 1 1 1 1 1 1 S=rats(x)S =1/10 1/5 3/10 2/5 1/2 3/5 7/10 4/5 N,D=rat(x)N = 1 1 3 2 1 3 7 4D = 10 5 10 5

22、2 5 10 5 A=2 4 6;3 5 7;8 10 9A = 2 4 6 3 5 7 8 10 9 B=4 1 5;7 5 0;9 3 6B = 4 1 5 7 5 0 9 3 6 ABans = 0 1 1 0 0 1 0 1 1 A A=Bans = 0 1 1 0 1 1 0 1 1 A A=Bans = 0 0 0 0 1 0 0 0 0 A=Bans =1 1 1 1 0 1 1 1 1 A&Bans = 1 1 1 1 1 0 1 1 1 A|Bans = 1 1 1 1 1 1 1 1 1 Aans = 0 0 0 0 0 0 0 0 0 Bans = 0 0 0 0 0 1

23、 0 0 0 x=0:pi/100:3*pi; y=sin(x); plot(x,y); y1=(x2*pi).*y; figure,plot(x,y1); r=(xpi/3&x7*pi/3&8*pi/3); rn=r; y2=r*sin(pi/3)+rn.*y1; figure,plot(x,y2) x=0 4 5 9 8 6 74 85 7 4 85 8 4 5 8x =0 4 5 9 8 6 74 85 7 4 85 8 4 5 8 all(x)ans =0 any(x)ans = 1 find(x)ans =2 3 4 5 6 7 8 9 10 11 12 13 14 15 isemp

24、ty(x)ans = 0 isglobal(x)Warning: isglobal is obsolete and will be discontinued. Type help isglobal for more details.ans =0 isinf(x)ans =0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 isnan(x)ans =0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 isfinite(x)ans =1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 issparse(x)ans = 0 isstr(x)ans =0 not(x)ans =

25、1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y=59 46 78 2 3 98 1 2 3 57 9 5 66 8 900 5y =59 46 78 2 3 98 1 2 3 57 9 5 66 8 900 5 y=59 46 78 2 3 98 1 2 3 57 9 5 66 8 900 5 y = 59 46 78 2 3 98 1 2 3 57 9 5 66 8 900 5 x=0 4 5 9 8 6 74 85 7 4 85 8 4 5 8x = 0 4 5 9 8 6 74 85 7 4 85 8 4 5 8 A=4 -40 2; 23 50 17;18 29 14A

26、 = 4 -40 2 23 50 17 18 29 14 r,c=find(A=20&A bitand(12,6)ans = 4 bitshift(12,1)ans = 24 bitxor(12,1)ans =13 bitset(12,1)ans = 13 bitget(12,1)ans =0 A = 87 59 56 85 66 21 12 35 62 64 69 88 99 81A =87 59 56 85 66 21 12 35 62 64 69 88 99 81 A(2)ans =59 A(1,2,8)ans =87 59 35 A(9,6,2)ans =62 21 59 A(end-

27、4:end)ans =64 69 88 99 81 A(1:5,5:-1:1)ans = 87 59 56 85 66 66 85 56 59 87 A(3)=-1A = 87 59 -1 85 66 21 12 35 62 64 69 88 99 81 A(15)=-8A =87 59 -1 85 66 21 12 35 62 64 69 88 99 81 -8 A(20)=-1A = Columns 1 through 16 87 59 -1 85 66 21 12 35 62 64 69 88 99 81 -8 0 Columns 17 through 20 0 0 0 -1 A=ran

28、d(8)A = 0.9501 0.8214 0.9355 0.1389 0.4451 0.8381 0.3046 0.3784 0.2311 0.4447 0.9169 0.2028 0.9318 0.0196 0.1897 0.8600 0.6068 0.6154 0.4103 0.1987 0.4660 0.6813 0.1934 0.8537 0.4860 0.7919 0.8936 0.6038 0.4186 0.3795 0.6822 0.5936 0.8913 0.9218 0.0579 0.2722 0.8462 0.8318 0.3028 0.4966 0.7621 0.738

29、2 0.3529 0.1988 0.5252 0.5028 0.5417 0.8998 0.4565 0.1763 0.8132 0.0153 0.2026 0.7095 0.1509 0.8216 0.0185 0.4057 0.0099 0.7468 0.6721 0.4289 0.6979 0.6449 A(3,3)ans =0.4103 A(8)ans =0.0185 sub2ind(size(A),3,3)ans =19 i,j=ind2sub(size(A),19)i =3j =3 A(:,4)ans =0.1389 0.2028 0.1987 0.6038 0.2722 0.19

30、88 0.0153 0.7468 A(3,:)ans =0.6068 0.6154 0.4103 0.1987 0.4660 0.6813 0.1934 0.8537 A(end,:)ans =0.0185 0.4057 0.0099 0.7468 0.6721 0.4289 0.6979 0.6449 A(3:4,5:6)ans =0.4660 0.6813 0.4186 0.3795 A(2:2:4,1:2:5)ans =0.2311 0.9169 0.9318 0.4860 0.8936 0.4186 A=reshape(A,5,5)A = 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25 A(:)ans =Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 25 17 18 19 20 21 22 23 24 25 A(:,1:2:5)=A = 6 16 7 17 8 18 9 19 10 20 A=9 8 7;6 5 4;3 2 1; D=diag(A)D =9 5 1 D1=diag(A,1)D1 =8 4 D2=diag(A,-1)D2 =6

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁