收藏 分销(赏)

matlab实验一Matlab基本操作、M文件及流程控制语句.doc

上传人:仙人****88 文档编号:7376778 上传时间:2025-01-01 格式:DOC 页数:7 大小:70KB
下载 相关 举报
matlab实验一Matlab基本操作、M文件及流程控制语句.doc_第1页
第1页 / 共7页
matlab实验一Matlab基本操作、M文件及流程控制语句.doc_第2页
第2页 / 共7页
matlab实验一Matlab基本操作、M文件及流程控制语句.doc_第3页
第3页 / 共7页
matlab实验一Matlab基本操作、M文件及流程控制语句.doc_第4页
第4页 / 共7页
matlab实验一Matlab基本操作、M文件及流程控制语句.doc_第5页
第5页 / 共7页
点击查看更多>>
资源描述

1、MATLAB实验报告实验一班级:电 信 0804姓名:田 佳 奇学号:1404080620完成时间:2011-3-20实验一 MATLAB基本操作、M文件和流程控制语句一、实验目的1、熟悉 Matlab 的开发环境、熟悉 Matlab 中的运算符。2、掌握建立矩阵的方法,掌握相关命令操作。3、理解命令M 文件和函数M 文件的区别。掌握M 文件的创建和运行。4、掌握流程控制语句的使用,掌握程序调试的基本方法。二、实验内容1、计算以下表达式的值,将结果按不同格式输出。掌握format 命令的使用方法。(1) y=(1.33)*sin(pi/3)*sqrt(26)y =9.7017 format s

2、hort e yy = 9.7017e+000(2) x=2,1+2i;-0.45,5;y=(1/2)*log(x+sqrt(1+x2)y = 7.1140e-001 -2.5314e-002i 8.9680e-001 +3.6577e-001i 2.1387e-001 +9.3428e-001i 1.1541e+000 -4.4259e-003i format short yy = 0.7114 - 0.0253i 0.8968 + 0.3658i 0.2139 + 0.9343i 1.1541 - 0.0044i(3) x=-3.0:0.1:3.0;y=(exp(0.3*x)-exp(-0

3、.3*x)/2).*sin(x+0.3)+log(0.3+x)/2)y = Columns 1 through 4 0.73882 +3.1416i 0.76961 +3.1416i 0.7871 + 3.1416i 0.79127 + 3.1416i Columns 5 through 80.78221 +3.1416i 0.76015 +3.1416i 0.72541 +3.1416i 0.6784 +3.1416i Columns 9 through 120.61961 +3.1416i 0.54956 +3.1416i 0.46883 +3.1416i 0.37797 +3.1416i

4、 Columns 13 through 160.27753 +3.1416i 0.16798 +3.1416i 0.049691+3.1416i -0.077109 +3.1416i Columns 17 through 20-0.21243+3.1416i -0.35659+3.1416i -0.51038+3.1416i -0.67524+3.1416i Columns 21 through 24-0.85364+3.1416i -1.0497+3.1416i -1.2701+3.1416i -1.5271+3.1416i Columns 25 through 28-1.8436 +3.1

5、416i -2.2727+3.1416i -2.9837 + 3.1416i -37.024 Columns 29 through 32-3.0017 -2.3085 -1.8971 -1.5978 Columns 33 through 36-1.3575 -1.1531 -0.97233 -0.80828 Columns 37 through 40-0.65675 -0.51514 -0.38189 -0.25611 Columns 41 through 44-0.13736 -0.025542 0.079223 0.17665 Columns 45 through 480.26633 0.

6、34781 0.42057 0.48411 Columns 49 through 520.53791 0.58152 0.61452 0.63658 Columns 53 through 560.64744 0.64696 0.6351 0.61194 Columns 57 through 600.57768 0.53269 0.47744 0.41256 Column 610.338852、已知求下列表达式的值:(1) A+6*B和A-B+I; a=12,34,-4;34,7,87;3,65,7; b=1,3,-1;2,0,3;3,-2,7; a+6*bans = 18 52 -10 46

7、7 10521 53 49 I=ones(3); a-b+Ians = 12 32 -2 33 8 85 1 68 1(2)A*B和A.*B a*bans = 68 44 62 309 -72 596 154 -5 241 a.*bans = 12 102 4 68 0 261 9 -130 49(3)A3和A.3 a3ans = 37226 233824 48604 247370 149188 600766 78688 454142 118820 a.3ans = 1728 39304 -64 39304 343 658503 27 274625 343(4)A/B 和BA abans =

8、-0.031311 0.30287 -0.33243 0.044188 -0.032281 0.10625 0.031669 -0.11577 0.15585 a/bans = 16.4 -13.6 7.6 35.8 -76.2 50.2 67 -134 68(5)A,B和A(1,3,:);B2 a,bans = 12 34 -4 1 3 -1 34 7 87 2 0 3 3 65 7 3 -2 7 a(1,3,:);b2ans = 12 34 -4 3 65 7 4 5 1 11 0 1920 -5 403、已知(1)当时,求y的值;创建函数的M文件:f31.m如下:function a=f

9、(n)a=n+10*log(n2+5)命令窗口调用: y=f31(40)/(f31(30)+f31(20)y = 0.63895(2)当时,求y的值;创建函数的M文件:f32.m如下:function b=f(n)b=0;while n=1 b=b+n*(n+1); n=n-1;end命令窗口调用: y=f32(40)/(f32(30)+f32(20)y = 1.76624、请分别用if 和switch 语句实现。输入一个百分制成绩,要求输出成绩等级A、B、C、D、E。其中90 分100分为A,80 分89 分为B,70 分79 分为C,60 分69 分为D,60 分以下为E。(1) if语句

10、实现:disp(conversion under if statement);n=input(please enter a percentile scores:);if n89 disp(A);elseif n79 disp(B);elseif n69 disp(C);elseif n59 disp(D);else disp(E);end(2) switch语句实现:disp(conversion under switch statement);n=input(please enter a percentile scores:);a=fix(n/10);switch a case 10 dis

11、p(A); case 9 disp(A); case 8 disp(B); case 7 disp(C); case 6 disp(D); otherwise disp(E);end5、已知:求中:(1) 这100个数中的最大值、最小值,这100个数的总和;(2) 统计正数、零、负数的个数;创建M文件:f5.m代码如下:sum=2;f1=1;f2=0;f3=1;max=1;min=0;n=4;positive=2;negative=0;zero=1;while nmax max=f; elseif f0 positive=positive+1; elseif f f5the max=437763282635.000000the min=-899412113528.000000the sum=-742745601951.000000the number of positive:49.000000the number of negative:49.000000the number of zero:2.000000

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 教育专区 > 小学其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服