dec2bin(40) ans = 101000 type dataex2.m X = [ 1 2 3 ; 0 1 1; 1 1 0] ; Y = [ 2 0 2 ; 2 1 2; 2 2 1; 2 2 2]; Z = [ 2 2 2 ; 2 1 2; 1 2 1]; R= [1 2 2 ]; S= [1 ; 1; 1 ]; T=['COMPUTER' 'Science?']; W=['Computer';'SCIENCES']; z X X = 1 2 3 0 1 1 1 1 0 X(1,1) ans = 1 X(end,1) ans = 1 X(1,end) ans = 3 X X = 1 2 3 0 1 1 1 1 0 X(end,end) ans = 0 X(1:end) ans = 1 0 1 2 1 1 3 1 0 X(end) ans = 0 W W = Computer SCIENCES dataex2 W W = Computer SCIENCES W(1,4:6) ans = put W(2,7) ans = E W W = Computer SCIENCES W(4) ans = C i*i ans = -1 j*j ans = -1 i/i ans = 1 W W = Computer SCIENCES whos Name Size Bytes Class Attributes R 1x3 24 double S 3x1 24 double T 1x16 32 char W 2x8 32 char X 3x3 72 double Y 4x3 96 double Z 3x3 72 double ans 1x1 8 double p2b = 5+ ~ 1 & ~ 0 p2b = 1 whos p2b Name Size Bytes Class Attributes p2b 1x1 1 logical p3a= 1:2:5 p3a = 1 3 5 whos p3a Name Size Bytes Class Attributes p3a 1x3 24 double Y Y = 2 0 2 2 1 2 2 2 1 2 2 2 Y(1:2,2:end) ans = 0 2 1 2 whos ans Name Size Bytes Class Attributes ans 2x2 32 double T T = COMPUTERScience? length(T) ans = 16 whos Name Size Bytes Class Attributes R 1x3 24 double S 3x1 24 double T 1x16 32 char W 2x8 32 char X 3x3 72 double Y 4x3 96 double Z 3x3 72 double ans 1x1 8 double p2b 1x1 1 logical p3a 1x3 24 double Y Y = 2 0 2 2 1 2 2 2 1 2 2 2 size(Y) ans = 4 3 whos ans Name Size Bytes Class Attributes ans 1x2 16 double length(Y) ans = 4 whos ans Name Size Bytes Class Attributes ans 1x1 8 double for ii=2:2:11 ; disp(ii); end 2 4 6 8 10 for ii=2:2:10 ; disp(ii); end 2 4 6 8 10 (2:2:10)' ans = 2 4 6 8 10 ii=2; while (ii<=10); disp(ii); ii=ii+2; end 2 4 6 8 10 dir . .. dataex2.m ex2cs101f11.m exam2.m exam2p4.m exam2p4a.m exam2p6.m exam2p7to9.m exam2p8.m exam2p9.m myqz5.m myqz6.m myqz6a.m myqz6b.m myqz6c.m type exam2p7to9.m a=exam2p7(5); exam2p8(); [c d]=exam2p9(40,10) [a b]=exam2p9(20,10) type exam2p6.m fprintf('p6a: For loop\n'); for ii = 1:10 disp(ii); end fprintf('p6b: while loop\n'); ii=0; while (ii < 10) ii=ii+1; disp(ii); end fprintf('p6c: No loop\n'); ii = 1:10 ; ii' clear dir . .. dataex2.m ex2cs101f11.m exam2.m exam2p4.m exam2p4a.m exam2p6.m exam2p7to9.m exam2p8.m exam2p9.m myqz5.m myqz6.m myqz6a.m myqz6b.m myqz6c.m edit in7.m type in7.m function y=in7(n) for jj=1:n my(jj) = jj ^ 4; end y=my; end tic;in7(10000);toc Elapsed time is 0.010447 seconds. tic;in7(100000);toc Elapsed time is 0.031810 seconds. tic;in7(1000000);toc Elapsed time is 0.305958 seconds. tic;in7(10000000);toc Elapsed time is 3.017622 seconds. tic;in7(100000000);toc Elapsed time is 29.779137 seconds. tic;in7(1000000000);toc edit in7.m in7(10000000); tic;in7(10000000);toc Elapsed time is 1.094129 seconds. edit in7.m tic;in7(10000000);toc Elapsed time is 0.257897 seconds. edit in7.m tic;in7(10000000);toc Elapsed time is 0.313177 seconds. tic;in7(10000000);toc Elapsed time is 0.294437 seconds. [a b] =exam2(5) a = 15 b = 3 type exam2.m function [ a b ] = exam2(n) a= sum(1:n); b= a/n; end type myqz5.m % myqz5 This is line 1 function z= myqz5(z) % line 2 function z= myqz5a (z) % line 3 z= z+z; % line 4 end % line 5 function z= myqz5b (z) % line 6 z= z+z+z; % line 7 end % line 8 z= myqz5a(z)+myqz5b(z)+myqz5c(z); % line 10 return; % line 11 end % line 12 function z=myqz5a(z) % line 13 z= z+z+z+z; % line 14 end % line 15 function z=myqz5c(z); % line 16 z= myqz5a(z)+z; % line 17 end % line 18