X = [ 1 4 4 1 ; 2 8 8 2; 3 6 6 3] ;
Y = [ 1 1 2 ; 2 1 1];
Z = [ 1 2 1 2 ];
R= [1 ; 2 ;1  ];
S= [1   2  3 ];
%
%
fprintf('1.  *******************  Problem 1. \n')
%
fprintf('1.1 *********  1MB       = %d\n', 1000000)
fprintf('1.2 *********  1KiB      = %d\n', 1024 )
%
ans=double(32); zorro=whos('ans');
fprintf('1.3 *********  1double   = %d\n', zorro(1).bytes)
%
ans=char(1); zorro=whos('ans');
fprintf('1.4 *********  1char     = %d\n', zorro(1).bytes)
%
ans=logical(1); zorro=whos('ans');
fprintf('1.5 *********  1logical  = %d\n', zorro(1).bytes)
%
fprintf('1.6 ********* int8       : values= %d , min =  %d , max= %d\n',256,int8(-128),int8(127))
fprintf('1.7 ********* X(end-2)   = %d\n', X(end-2)  )
fprintf('1.8 ********* X(end,end) = %d\n', X(end,end)  )
fprintf('1.9 ********* Y(end-2)   = %d\n', Y(end-2)  )
fprintf('1.10********* 20 in hex  = %2x\n',20)
%
input('Press ENTER to Continue');
%
fprintf('2.  *******************  Problem 2. \n')
A= 5<5<5;
A;
zorro=whos('A');
fprintf('2.a.1********       = %2d  %2d x %2d  %2d    %s\n',A, zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
%
A = 2^1^2;
A;
zorro=whos('A');
fprintf('2.a.2********       = %2d  %2d x %2d  %2d    %s\n',A, zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
A = true == false + true;
A;
zorro=whos('A');
fprintf('2.a.3********       = %2d  %2d x %2d  %2d    %s\n',A, zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
A = int16(5 < 5 + 5);
A;
zorro=whos('A');
fprintf('2.a.4********       = %2d  %2d x %2d  %2d    %s\n',A, zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
A = 13:-3:1;
A;
zorro=whos('A');
fprintf('2.a.5********       = [%2d %2d %2d %2d %2d ]  %2d x %2d  %2d    %s\n',A(1),A(2),A(3),A(4), A(5), zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
%
clear A;
A(4)= 14;
zorro=whos('A');
fprintf('2.b.1********       = [%2d %2d %2d %2d ]  %2d x %2d  %2d    %s\n',A(1),A(2),A(3),A(4), zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
A(4,4)= 24;
zorro=whos('A');
fprintf('2.b.2********       = %s  %dx%d %2d  %s\n',mat2str(A), zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
%
%
input('Press ENTER to Continue');

fprintf('3.  *******************  Problem 3. \n')
q3a=  R * transpose(R) ;
fprintf('3.a ********    q3a = R*transpose(R)   is %s\n',mat2str(q3a));
q3b=  S * R;
fprintf('3.b ********    q3b = S*R              is %s\n',mat2str(q3b));
q3c=  S * transpose(S);
fprintf('3.c ********    q3c = S * transpose(S) is %s\n',mat2str(q3c));
zorro=whos('q3a');
fprintf('3.d.a *******            = %2d x %2d  %2d    %s\n', zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
zorro=whos('q3b');
fprintf('3.d.b *******            = %2d x %2d  %2d    %s\n', zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
zorro=whos('q3c');
fprintf('3.d.c *******            = %2d x %2d  %2d    %s\n', zorro(1).size(1),zorro(1).size(2),zorro(1).bytes,zorro(1).class)
input('Press ENTER to Continue');
%
fprintf('4.  *******************  Problem 4. \n')
%
q4a= 5  / 1 / 5 ; 
q4b=  5 < 5 < 1 ;
q4c=  NaN == NaN ;
q4d= 5 & 5;
q4e= 5 + 5 & 5 < 5;
%
fprintf('4.  ********* q4a = %d ,q4b = %d ,q4c = %d ,q4d = %d , q4e = %d \n',q4a,q4b,q4c,q4d,q4e)
%
input('Press ENTER to Continue');
 
%
%

fprintf('5.  *******************  Problem 5. \n')

%
fprintf('5.a. Column-major %s \n',mat2str(Y(1:end)));
%
YY=Y';
fprintf('5.b. Row-major    %s \n',mat2str(YY(1:end)));
%

input('Press ENTER to Continue');



%
fprintf('6.  *******************  Problem 6. \n')
%

q6a= round(2*rand()+3) ;
fprintf('6.a  ************    q6a = [min=%f  , max=%f]\n',3,5); 
%
q6b= 2*ones(3)+eye(3)+5;
fprintf('6.b  ************    q6b = %s\n',mat2str(q6b)); 
%
q6c= 1:3:10;
fprintf('6.c  ************    q6c = %s\n',mat2str(q6c)); 
%
q6aux=1:5;
q6d= (-1) .^ q6aux;
fprintf('6.d  ************    q6d = %s\n',mat2str(q6d)); 
%
q6aux=1:5;
q6e=  q6aux .^ 2;
fprintf('6.e  ************    q6e = %s\n',mat2str(q6e)); 
%
q6f=  1:3:10 == 3;
fprintf('6.f  ************    q6f = %s\n',mat2str(q6f)); 
%
q6g=  X(: , 1:1:2);
fprintf('6.g  ************    q6g = %s\n',mat2str(q6g)); 
%
q6h=  X;
q6h (:, 2:end) = [];
fprintf('6.h  ************    q6h = %s\n',mat2str(q6h)); 
%
%
%
%
%
%
%
input('Press ENTER to Continue');
fprintf('7.  *******************  Problem 7. \n')
  q7a  = 2;
  q7b  = 10;
  q7c  = q7a + q7b;
  q7a  = 2 * q7a;
  q7b  = q7b / 2;
  q7c  = q7a + q7b + q7c ;

fprintf('7.a *******************  q7a = %f , q7b = %f  q7c = %f \n',q7a,q7b,q7c);

 q7d  = 10 ;
 q7f  = 20;
 q7   = 0;
 q7   = q7d;  q7d = q7f ; q7f = q7;

fprintf('7.b *******************  q7d = %f , q7f = %f\n',q7d,q7f);

 q7g  = 10 ;
 q7h  = q7g + q7g;
 q7h  = q7g + q7h;

fprintf('7.c *******************  q7g = %f , q7h = %f\n',q7g,q7h);


fprintf('\n');
fprintf('8.  *******************  Problem 8. \n')
fprintf('8.  The missing lines are           \n')
fprintf('    *******************             \n')

fprintf('8a. b = 1./ b ;            %% Line 5    \n');
fprintf('8a. c = sum(b);            %% Line 6    \n');
fprintf('\n\n');
