1、MATLAB及其工程应用B卷10级试题编号: 重庆邮电大学 2010/2011 学年 2学期MATLAB及其工程应用(普通班)试卷(期末)(B)(闭卷)题 号一二三四五六七八总 分得 分评卷人一、Fill in the blanks.(1 scores each. Total 30 scores.)1.1 Use MATLAB operator : to generate the vector of 0, , , _ _1.2 An is a collection of data values organized into rows and columns,and known by a sin
2、gle name.1.3 Write the results of the following MATLAB statements, if there is an error, please fill “error”.1)a=1 2 3;4 5 6, a(5)= _; a(8)= _;a(-2)= _ 2) x = 1:0.02:10; x = 3) u = 1:3 ; u u = _ _4) zeros(3,2) = _ _; ones(3) = _ _; a = 11 14 17; 12 15 18; 13 16 19 ;I=eye(3); a * I= _ _5) z = -2 0 9
3、1 4 ; z(2) = 5; z =_ _6) u = 22 -3 15 7 0 ; u(1)= u(4); u =_ _7) v=12 13 -3 9 -11 ; v(6)=7, v =_ _8) w = 1 4 7; 2 5 8; 3 6 9 ; w(2:end,2:end) = 0; w =_ _9) c = 1 2 3; 4 5 6; 7 8 9 ; c(1,1 3) = -3; c=_ _10) date = num2str(1) -July- num2str(2011) ; ans = _ _11) fprintf( Area of a circle with radius %d
4、 is %7.4f, 2, pi*22 );ans = _ _12)a = 1 2; 3 4 ; b = 5 6; 7 8 ; a+b= _;a*b= _; a.*b= _;2a= _1.4 Assume that array array1 is defined as shown, and determine the contents of the following sub-arrays. array11 = 4 3 2 1; 4 6 7 8; 9 10 11 12 1) array11(3, :) = _ _ 2) array11(1:3, 2 2 3 3) = _ _ 3) array1
5、1(2 3, 4 3) = _ _1.5 Assume that a,b,c,and d are as defined,and evaluare the following expressions:a=0,5;3,-2; b=-1,2;0,3; c=2; d=3,-5,7;1,0,21) (ab)ans = _ _ _2) ac&bcans = _ _ _3) aa*cans = _ _2) d|baans = _ _ _3) (d|b)a ans = _ _ _二、Chose the best answer for the following questions.2 scores each.
6、 Total 20 scores.)2.1 Among the following MATLAB variable names, the illegal one is A. Faint B. dont_bother_me C. Help_me D. godSaveMe 2.2 A = 1 2 3; 9 6 5; 3 4 7, then A(1, :) is _ _ A. 1 2 3 B. 1 C. 1; 7 D. 1 2 3; 9 6 5; 3 4 7 2.3 Among the following comments about MATLAB, the correct one is _ _ A
7、. MATLAB can not plot 3-D pictures B. MATLABs variables need to be defined before they are used C. A MATLAB function can return more than 1 variable D. A MATLAB array can not have string inside2.4 About the simultaneous equations(线性方程组)Ax = b, the following MATLAB statement which can solve the value
8、 of x is _ A. x = A/b B. x = A./b C. x = Ab D. x = A.b2.5 Assume x=1:-2:-8, then x(1 5) is _ _ A 1,-8 B-1, -7 C-1, -8 D 1, -72.6 Among the following MATLAB expressions, _ _ has the different result. A. 34 B. pi=3.1415 C. floor(pi) - 3 D. zeros(1,2) 2.7 The execute result of MATLAB expression a = 7+5
9、*3/4-sin(pi/2) is _ _ A. a = 12 B. a = 8 C. a = 9.75 D. a = 10.75 2.8 After execute the following MATLAB expressions, the result of s is_ _ s = 0; for k = 1:10 if k5 continue; end s = s + k; end A. s = 10 B. s = 15 C. s = 55 D. s = 6 2.9 Among the following matlab expressions, _ _ has no errors. A.
10、a = 3; a(3) = 3; B. a = zeros(1, 2) ones(2, 1) C. a = 1 2; b = 3 4 5; c =a*b; D. t=1:10; y=t*t+1;2.10 After execute the following MATLAB expressions, the result of y is _ y=; for t = -1:2 y = y t2; end A. B. error C. 1 0 1 4 D. 1 2 3三、Read the following MATLAB statements and write the execute result
11、s. (4 scores each. Total 20 scores.)3.1 format short;s1 = 0;while s1=0 % 能正确运用if语句,给2分 Y(k)=-7*t.*t-sqrt(t)+exp(3); %能正确写出表达式给1分 else Y(k)=7*t.*t+sqrt(t)+exp(3); endend五、x=0:pi/20:pi*2; %正确产生x的值以及正确产生y1、y2给1分y2=x.2+3*x-7; y1=sin(2*x)+3;plot(x,y1,:,x,y2,-); %1分title(y1(x) and y2(x) %1分xlabel(x);ylabe
12、l(y1 and y2);%1分legend(y1,y2); %1分grid on; %1分六、由于题目维数不一致,所以去掉最后一行。试卷中只要思想和代码的写法正确即算正确clca=-0.2 5.0 1.0 3.0 4.0 2.0 -1.0 -0.5 -2.0 6.0 -1.0 6.0 -4.0 -5.0 -2.0 4.0 3.0 -6.0 -5.0 -2.0 -3.0 6.0 4.0 2.0 -6.0b=0.0;1.0;-6.0;10.0;-6.0 %正确写出矩阵3分x=ab %正确得出结果3分七、function plottangentx=-5:0.1:5;y=coshf(x); %正确调用给2分plot(x,y); function y=coshf(x) %正确写出函数3分y=(exp(x)+exp(-x)/2; %正确完成功能给1分八、function factn=input(n=) %if(n0) y=myfun(n); %调用函数及显示2分 fprintf (%d!累加和=%d,n,y)endfunction s=myfun(n) %被调函数2分s=0;for k=1:n s=s+factorial(k);end
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2