正在加载图片...
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 between2 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:
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有