杭州电子科技大学学生考试卷 (A) 卷 考试课程 课程号 学生姓名 MATLAB Language and Simulation 6). If user enters a name at the MATLAB prompt, which is the correct sequence of the MATLAB attempts to find the name? ( ) A. M-files→built-in function/command→variable 考试日期 年 月 日 任课教师 班级 成绩 B. M-files→variable→built-in function/command B0802210 教师号 学号(8位) C. variable→built-in function/command→M-files D. built-in function/command→variable→M-files 1.Choice(each 2, total 20) 1).Which description about MATLAB language is wrong? ( ) A. MATLAB execute more slowly than compiled language. B. MATLAB has a lot of functions. C. MATLAB is supported on many different computer systems. D. In MATLAB, the type and name of every variable must be explicitly declared. 2). Which command can display the contents of a workspace? ( ) A. clear B. whos C. diary D. clc 3).Which expression is illegal? ( ) A. [1, 2, 3] B. [1 2 3; 4 5] C. [1; 2; 3] D.[1:6] 4). Which command can not let user to get help in MATLAB? ( ) D. A. help B. lookfor C. demo D. load 5). Variable a = ‘3.1415’, b = eval (a), so the size of variable a and b is ( ) A. 6 bytes /8 bytes B. 12 bytes / 8bytes C. 8 bytes / 8bytes D. 10 bytes / 8 bytes 7). The result of expression 5/0 is ( ) A. NAN B. Inf C. eps D. 0 8). If a???1??40??1and b???3??5?2??, then the result of a??bis ( ) ?1? ?1A.??00??1? B. 0 C. 1 D.?1??10?? 0?9). Which function can plots x data on linear axes and y data on logarithmic axes? ( ) A. plot B. semilogx C. semilogy D. loglog 10). Solve for x in the equation Ax?B, then x? ( ) A. A / B B. A \\ B C. A ./ B D. A .\\ B 2.Judgement(each 2, total 20) 1). User can not use a variable with the same name as a MATLAB function or command. ( ) 2). a / b == b \\ a ( ) 第1页 共3页
3). In MATLAB, the type and name of every variable need not to be explicitly declared ( ) 4). a = 4+3i, b =2+10i, the result of (a0 (a) c (1:2, 2:end) (b) c ([2 2], [3 3]) (c) d (: , : , 1)= c d (:, : , 2) = c+1 4. Evaluate each of the following expressions. (9) (a) a = [1 2 3], a(8) = 8, so a is? (b) 2*(3-1)+2*2^3 = ? 7. Examine the following for loop, determine the value of ires at the end of each of the loop, and also the number of times each loop executes. (12) (a) ires = 0; for index = 1:10; ires = ires + 1; end 第2页 共3页
(b). ires = 0; for index = 1:10; ires = ires + index; end (c) ires = 0; for index1 = 1:10; for index2 = index1:10 if index2 == 6 break; end ires = ires + 1; end end (d) ires = 0; for index1 = 1:10; for index2 = index1:10 if index2 == 6 continue; end ires = ires + 1; end end 8. Design a function named maximum. If there only one output argument, returns the maximum value of the input array. If there are two output arguments, returns both the maximum value and the according subscript number. If the input argument is null, displays an error message. Do not use MATLAB built-in function max( )! (10) 第3页 共3页