正在加载图片...
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)<3 A(i, j) = A(i, j)^2; elseif A(i, j) > 7 A(i, j) = - A(i, j); end; end; end;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有