matlab软件技术--作业1Matlab软件技术—作业1
学号:10094152 姓名:郑焕魁 班级:机设优090
一、 求下列表达式的值。要求给出程序和执行结果
1、
2、
提示:用冒号表达式生成a向量,求各点的函数值时用点乘运算。
答:
1.程序:
>> e=2.71828;
>> z1=2*sin(85*pi/180)/(1+e^2)
执行结果:
z1 =
0.2375
2.程序:
>> a=(-3.0:0.1:3.0);
>> z2=exp(0.3*a)/2.*sin(a+0.3)+log((0.3+a)/2)
执行结果:
z2 =
Co...
Matlab软件技术—作业1
学号:10094152 姓名:郑焕魁 班级:机设优090
一、 求下列表达式的值。要求给出程序和执行结果
1、
2、
提示:用冒号表达式生成a向量,求各点的函数值时用点乘运算。
答:
1.程序:
>> e=2.71828;
>> z1=2*sin(85*pi/180)/(1+e^2)
执行结果:
z1 =
0.2375
2.程序:
>> a=(-3.0:0.1:3.0);
>> z2=exp(0.3*a)/2.*sin(a+0.3)+log((0.3+a)/2)
执行结果:
z2 =
Columns 1 through 3
0.2132 + 3.1416i 0.1544 + 3.1416i 0.0940 + 3.1416i
Columns 4 through 6
0.0321 + 3.1416i -0.0312 + 3.1416i -0.0956 + 3.1416i
Columns 7 through 9
-0.1613 + 3.1416i -0.2280 + 3.1416i -0.2958 + 3.1416i
Columns 10 through 12
-0.3647 + 3.1416i -0.4346 + 3.1416i -0.5058 + 3.1416i
Columns 13 through 15
-0.5783 + 3.1416i -0.6526 + 3.1416i -0.7289 + 3.1416i
Columns 16 through 18
-0.8080 + 3.1416i -0.8906 + 3.1416i -0.9780 + 3.1416i
Columns 19 through 21
-1.0718 + 3.1416i -1.1742 + 3.1416i -1.2884 + 3.1416i
Columns 22 through 24
-1.4195 + 3.1416i -1.5749 + 3.1416i -1.7673 + 3.1416i
Columns 25 through 27
-2.0205 + 3.1416i -2.3881 + 3.1416i -3.0400 + 3.1416i
Columns 28 through 30
-37.0245 -2.9487 -2.2062
Columns 31 through 33
-1.7494 -1.4088 -1.1318
Columns 34 through 36
-0.8951 -0.6866 -0.4996
Columns 37 through 39
-0.3296 -0.1741 -0.0314
Columns 40 through 42
0.0996 0.2196 0.3287
Columns 43 through 45
0.4272 0.5150 0.5921
Columns 46 through 48
0.6583 0.7134 0.7571
Columns 49 through 51
0.7894 0.8101 0.8191
Columns 52 through 54
0.8164 0.8021 0.7762
Columns 55 through 57
0.7391 0.6911 0.6325
Columns 58 through 60
0.5641 0.4864 0.4003
Column 61
0.3068
二、 已知
,
求下列表达式的值:要求给出执行结果
1、 A+6*B,A-B+I(其中I为单位矩阵)
2、 A*B,A.*B
3、 A^3,A.^3
4、 A/B,B\A
5、 [A,B],[A([1,3],:);B^2]
答:
1. a =
18 52 -10
46 7 105
21 53 49
b =
12 31 -3
32 8 84
0 67 1
2. c =
68 44 62
309 -72 596
154 -5 241
d =
12 102 4
68 0 261
9 -130 49
3. e =
37226 233824 48604
247370 149188 600766
78688 454142 118820
f =
1728 39304 -64
39304 343 658503
27 274625 343
4. g =
16.4000 -13.6000 7.6000
35.8000 -76.2000 50.2000
67.0000 -134.0000 68.0000
h =
109.4000 -131.2000 322.8000
-53.0000 85.0000 -171.0000
-61.6000 89.8000 -186.2000
5. i =
12 34 -4 1 3 -1
34 7 87 2 0 3
3 65 7 3 -2 7
j =
12 34 -4
3 65 7
4 5 1
11 0 19
20 -5 40
三、 求矩阵A的主对角线元素、上三角阵、下三角阵、秩、范数、条件数和迹。要求给出程序和执行结果
答:
>> A=[1 -1 2 3;5 1 -4 2;3 0 5 2;11 15 0 9];
>> a=diag(A)
a =
1
1
5
9
>> b=triu(A)
b =
1 -1 2 3
0 1 -4 2
0 0 5 2
0 0 0 9
>> c=tril(A)
c =
1 0 0 0
5 1 0 0
3 0 5 0
11 15 0 9
>> d=rank(A)
d =
4
>> e=norm(A)
e =
21.3005
>> f=cond(A)
f =
11.1739
>> g=trace(A)
g =
16
四、 输入一个百分制成绩,要求输出成绩等级A、B、C、D、E。其中90分~100分为A,80分~89分为B,70分~79分为C,60分~69分为D,60分以下为E。
分别用if语句和switch语句实现;输入百分制成绩后要判断该成绩的合理性,对不合理的成绩应输出出错信息。要求给出程序
答:
x=input('请输入成绩');
if x>=90&x<=100 disp('A');
elseif x>=80&x<90 disp('B');
elseif x>=70&x<80 disp('C');
elseif x>=60&x<70 disp('D');
elseif x<60&x>=0 disp('E');
else disp('wrong');
end
五、 考虑迭代
,编写程序求迭代结果,迭代的终止条件为
,迭代初值
,迭代次数不超过500次。要求给出程序
答:
format long
x=1;
y=0;
for i=1:500
y=x;
x=2/(x+2);
if abs(x-y)<=10^(-5)
break
end
end
x
继续阅读
本文档为【matlab软件技术--作业1】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。