当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

同济大学:《Matlab在机械设计中的应用》课程教学资源(试卷习题)Final Examination(B)The First Semester(2013-2014)

资源类别:文库,文档格式:PDF,文档页数:6,文件大小:614.15KB,团购合买
点击下载完整版文档(PDF)

Final Examination of Tongji University (B) &e p品器器一 The First Semester(2013---2014) then use MATLAB to generate this vector: 7.Suppose that a =[12;34]and b=[-13;2-1]. Paper-making Teacher:CHEN Ming Audit Teacher:Hans WIEDMANN If you typeab in the command window,then can get Course Number:_ Course Name:Matlab programming for Mechanical Design If you the cmmand window,then Time:120minutes Maximum Marks:100 and ,and must begin with Grade 一Mpr Number Name Marks a 9.You can type to list al the variables in the current workspace,together with information about their sie, I.Fill in the blanks.(50X1') bytes,class,etc. 1.Suppose that you were looking for the,You will use the function 10.x=o2 s V=- Suppose that you were going toclear the information in command window,You wuse the function: z=cne2,3引 2= t=2 eros(length(z)】t= Suppose that you were going to cear the variables in the workspace,You will use the function: 11.Determine the contents ofrfter the followingstatementsrexeuted. 2.If you type MATLAB will display a list of possible help topics in the Command Window. 1)a=123:456789啡ap1=a13乳} 3.Write the resuts of the following MATLAB statements 1m=7:11;n=[m'm] 2a=12345G789外a12=a33乳 n= a= 2)a=eve(3,3):b=[123]:a[2.:)=b: 3)a=123:456789外a=al11.) 3 1=_ 3)[zeros(1.3]ones(3,11:3 41=123:456789外a2:cnd,2:end=2 ans= a=_ 4.Suppose that a=[123;456;789]andb=a>5. 12.Determine the subscript of the array. b= 1)A=[4101;9756](Warning:for example,A(1)=4 and you should use only one subscript!) s(~b)= a A(=多 ab)=a(b)42= length(abr。 218,:,14101:82g:75刀:66,:2=6254124:1521 5.Assume that array'aray'is defined as shown,and determine the contents of the following sub-arrays. [12-3541-271 BJ=12. array1 13.」 statement terminates the execution of a loop and passes the control to the next statement after the end of the loop ates the current pass through the loop and returns tthe top of the loop. 2)ra1p4,133玑= 14.Assume that value has initialized to 5.6443,and determine what is printed out by each of the following 3到rav101.B4'=

1 Final Examination of Tongji University(B) The First Semester (2013 --- 2014) Paper-making Teacher: CHEN Ming Audit Teacher: Hans WIEDMANN Course Number: Course Name: Matlab programming for Mechanical Design Time: 120 minutes Maximum Marks: 100 Grade Major Number Name Marks Ⅰ. Fill in the blanks. (50×1’) 1. Suppose that you were looking for a function to take the inverse of a matrix, You will use the function: ; Suppose that you were going to clear the information in command window, You will use the function: ; Suppose that you were going to clear the variables in the workspace, You will use the function: . 2. If you type , MATLAB will display a list of possible help topics in the Command Window. 3. Write the results of the following MATLAB statements. 1) m = 7:11; n = [m’ m’] n = ___ ; 2) a = eye(3,3); b = [1 2 3]; a(2,:) = b; a = _ _; 3) [zeros(1,3) ones(3,1)’ 1:3’] ans = _ . 4. Suppose that a = [ 1 2 3; 4 5 6; 7 8 9 ] and b = a > 5. b = ; a(b)= ; a(~b) = ; a(~~b)= ; a(~b) = a(~b).^2= ; length(a(b))= . 5. Assume that array 'array1' is defined as shown, and determine the contents of the following sub-arrays. array1 = [ 1.2 −3.5 4.1 −2.7 0.3 8.1 −7.6 1.8 3.1 0.7 0.5 0.4 1.4 5.7 0.2 1.0 ] 1) array1(2, :) = ; 2) array1(2:4, [1 3 3]) = ; 3) array1([1 1], [3 4])’ = . 6. Use MATLAB operator ':' to generate the vector of [ 𝜋 100 , 2𝜋 100 , 3𝜋 100 , …, 𝜋]: ; then use MATLAB linspace to generate this vector: . 7. Suppose that a = [1 2; 3 4] and b = [-1 3; 2 -1]. If you type a .* b in the command window, then can get: ; If you type a * b in the command window, then can get: . 8. MATLAB variable names can contain any combination of letters, and , and must begin with a . 9. You can type to list all the variables in the current workspace, together with information about their size, bytes, class, etc. 10. x = zeros(2) x = ; y = ones(size(x)) y = ; z = ones(2,3) z = ; t = zeros( length(z) ) t = . 11. Determine the contents of array ‘a’ after the following statements are executed. 1) a = [1 2 3; 4 5 6; 7 8 9]; a([3 1], :) = a([1 3], :) a = ; 2) a = [1 2 3; 4 5 6; 7 8 9]; a([1 2], :) = a([3 3], :) a = ; 3) a = [1 2 3; 4 5 6; 7 8 9]; a = a([1 1], :) a = ; 4) a = [1 2 3; 4 5 6; 7 8 9]; a(2:end, 2:end) = -2 a = . 12. Determine the subscript of the array. 1) A = [4 10 1; 8 2 9; 7 5 6] (Warning: for example, A(1) = 4 and you should use only one subscript!) A( ) = 5; 2) B(:, :, 1)=[4 10 1; 8 2 9; 7 5 7] ; B(:, :, 2)=[6 2 5; 4 12 4; 1 5 2] B( ) = 12. 13. statement terminates the execution of a loop and passes the control to the next statement after the end of the loop; statement terminates the current pass through the loop and returns control to the top of the loop. 14. Assume that value has been initialized to 5.6443, and determine what is printed out by each of the following

3 two points ()and (x2,y2)inaCartesian 1)disp(['value='int2str(value); coordinate system. 2)fprintf['value=0.2f,valuel: 5.%Define variables: 6.%x1 xposition of point1 15.After running the following codes,what will show on the MATLAB command window? 7%y1 osition of point1 x=0.1,020,3.041,2.3,4 8%2 xposition of point 2 try 9%2 yposition of point2 a=1,24 10.%distance catch 19.By executing the follewing Mfile,what in the commad window? a=xend,4); a=2b=64 end fprintf'before sample:a=fb=彩fn,ab站 3=. out=sample(a,b]: 16.X=2-23 fprintf('after sample:a=b str=['disp:x='num2str) fprintf('after sample:out=ffn,out); disp(strh fprintf('fprintf:x=8.4fnx): function out-sample(a,b) The results printed out by these statements are fprintf('In sample:a=b=.a.b: 17.Here is the input of a and b,please fill in the result in the table a=142'a b=a.女 b xor(a,b) out=a+b(1); 11 fprinti('In sample:a=%b=f fb) 01 In sample: 18.Here is a function and its comment lines.The lookfor command searches function according to the comment In sample: fine:_ _And the help command displays the comment lines from the line to line after sample: down the number before the comment line) after sample function distance=dist2(x1,v1,x2.y2) Calculate the distance between two points 2.%Function DST2 calculates the distance between

2 statements. 1) disp([‘value = ’ int2str(value)]); ; 2) fprintf(‘value = %0.2f’, value); . 15. After running the following codes, what will show on the MATLAB command window? x = [0, 1, 0, 2; 0, 3, 0, 4; 1, 2, 3, 4]; try a = x([1 1], [2 4]); catch a = x(2:end, 4); end a = . 16. X = 2*(1-2*i)^3; str = [‘disp: x = ’ num2str(X)]; disp(str); fprintf(‘fprintf: x = %8.4f\n’,x); The results printed out by these statements are . 17. Here is the input of a and b, please fill in the result in the table. a b xor(a, b) 1 1 0 1 18. Here is a function and its comment lines. The lookfor command searches function according to the comment line: . And the help command displays the comment lines from the line to line .(write down the number before the comment line) function distance = dist2(x1, y1, x2, y2) 1.%DIST2 Calculate the distance between two points 2.% Function DIST2 calculates the distance between 3.% two points (x1,y1) and (x2,y2) in a Cartesian 4.% coordinate system. 5.% Define variables: 6.% x1 -- x-position of point 1 7.% y1 -- y-position of point 1 8.% x2 -- x-position of point 2 9.% y2 -- y-position of point 2 10.% distance -- Distance between points 19. By executing the following M.file, what will appear in the command window? a = 2; b = [6 4]; fprintf(‘before sample: a = %f, b = %f %f \n’, a, b); out = sample(a, b); fprintf(‘after sample: a = %f, b = %f %f \n’, a, b); fprintf(‘after sample: out = %f %f \n’, out); function out=sample(a, b) fprintf(‘In sample: a = %f, b = %f %f \n’, a, b); a = b(1)+2*a; b = a.*b; out = a + b(1); fprintf(‘In sample: a = %f, b=%f %f \n’, a, b); before sample: ; In sample: ; In sample: ; after sample: ; after sample:

Name】 Number_ Major. ⅡP1ot(20') 2.Please complete the following figure:(4') 1.Please draw the figure which is displayed after the following statements:(4') x=0:0.1:pi x=123:23434 plot(x sinx) hold on y1=ones(3): Y2=13524357刀 plot(x cos(x)- subplot(211k titlesn/kost树n xlabelfx] plot(x,y1): subplot[212 ylabelfy) plot(x.y2:-] legend('sin(x.'cosx) tex(5,0.7,point of intersection grid on 2 0.8 05 15 2253 35 4 45 02 04 06 235445

Name Number Major 3 Ⅱ Plot(20’) 1. Please draw the figure which is displayed after the following statements: (4’) x = [1 2 3; 2 3 4; 3 4 5]; y1 = ones(3); y2 = [1 3 5; 2 4 6; 3 5 7]; subplot(211); plot(x, y1); subplot(212); plot(x,y2,’--’); 2. Please complete the following figure: (4’) x = 0: 0.1: pi; plot(x, sin(x)); hold on plot(x, cos(x), 'r--') title('sin(x)/cos(x)') xlabel('x') ylabel('y') legend('sin(x)', 'cos(x)') text(0.75, 0.7, 'point of intersection') grid on

3.The gain Gof a certain microwave dish antenna can be expressed as a function of angle by the equation G(0)=Isinc401 for-<< Where 8 is measured in radians from the boresite of the dish,and sincx-sinx/x.Plot this gain function with the fplot function,with the title"Antenna Gain vs 8"in boldface.(4') ⅢProgramming(30') 1. 4.Please write a program which will ge erate a figure as the following one.(8) Please write a MATLAB program to solve the following system of simultaneous equations for X.(3) 2X13%3+X+2%=8 poty-2.10+15 X+3X+%=6 XrX+X+8名=1 7%+Xr2X+2X=5

4 3. The gain G of a certain microwave dish antenna can be expressed as a function of angle by the equation 𝐆(𝛉) = |𝐬𝐢𝐧𝐜𝟒𝛉| 𝐟𝐨𝐫 − 𝛑 𝟐 < 𝛉 < 𝛑 𝟐 Where θ is measured in radians from the boresite of the dish, and sincx=sinx/x. Plot this gain function with the fplot function, with the title “Antenna Gain vs 𝛉”in boldface. (4’) 4. Please write a program which will generate a figure as the following one. (8’) Ⅲ Programming (30’) 1. Please write a MATLAB program to solve the following system of simultaneous equations for X.(3’) 2X1-3X2+X3+2X4 = 8 X1+3 X2+ X4 = 6 X1- X2+ X3+8 X4 = 1 7X1+ X2-2 X3+2 X4 = 5

Name】 Number_ Major. 2.Assume that a,b,c,and d are as defined,and evaluate the following expressions(6'): 4.Please modify the following program without using"for"loop.You can write the program using mask a=20:b=-2: (A mask is an array that selects the elements of another array),but the result shall be the same as this c=0;d='Test'; one.(4') 1)isinf(a/b) A-12345G789外 2)isinf(a/c) 3到a>b&ischard fori=1:1 4)isempty(c) for =1:1sc 5)(-a)b if A(i,k3 6)(a)+b AM.1=A,2 elseif Ai,>7 A=A正G end; end; end; 3.Please analyze the following two statements,which one is better?Why?(3) 1)foril=1:100 square(間=i2: square_root(l)=(1/2): cube_root(ii)=i(1/3); end 2h=1100 square(ii)=ll.2; square_root(il)=i(1/2): cube_root()=li.(1/3);

Name Number Major 5 2. Assume that a, b, c, and d are as defined, and evaluate the following expressions(6’): a = 20; b = -2; c = 0; d = 'Test'; 1) isinf(a/b) 2) isinf(a/c) 3) a > b && ischar(d) 4) isempty(c) 5) (~a) & b 6) (~a) + b 3. Please analyze the following two statements, which one is better? Why ?(3’) 1) for ii = 1:100 square(ii) = ii^2; square_root(ii) = ii^(1/2); cube_root(ii) = ii^(1/3); end 2) ii = 1:100 square(ii) = ii.^2; square_root(ii) = ii.^(1/2); cube_root(ii) = ii.^(1/3); 4. Please modify the following program without using “for” loop. You can write the program using mask (A mask is an array that selects the elements of another array), but the result shall be the same as this one. (4’) A=[1 2 3; 4 5 6; 7 8 9]; [r c]=size(A); for i=1:1:r for j=1:1:c if A(i, j) 7 A(i, j) = - A(i, j); end; end; end;

5.Try your best to create a function that accepts an(x,y)value in rectangular coordinates and produces 6.One simple random number generator algorithm is shown below,it will produce number between 0 the equlvalent polar representation consisting of a magnitude and an angle in degrees.(7) and134455. 41=m0d(8121m4+28411,134456) random matris,and the number in the matrix is.) 2)Sort the 1x10 random mat ix(thele is octed in theriht)(

6 5. Try your best to create a function that accepts an(x, y) value in rectangular coordinates and produces the equivalent polar representation consisting of a magnitude and an angle in degrees. (7’) 6. One simple random number generator algorithm is shown below , it will produce number between 0 and 134455. 𝒏𝒊+𝟏 = 𝒎𝒐𝒅(𝟖𝟏𝟐𝟏𝒏𝒊 + 𝟐𝟖𝟒𝟏𝟏, 𝟏𝟑𝟒𝟒𝟓𝟔) 1).Now you need to generate a 1x10 random matrix, and the number in the matrix is between 0 to 10.(3’) 2).Sort the 1x10 random matrix(the smallest is located in the right).(4’)

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
已到末页,全文结束
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有