%Matrix/vector definitions
a=2
a=2;
b=[1 2 ;
   3 4]
c=[b b]
c=[b ; b ; a a]
v=1:5
v=1:2:10
v=10:-2:1

%matrix operations
c=b+b;   c=b-b;
c=b*b;   c=b.*b;
c=b*2;   c=b.*2;
c=b./2; 
c=b.^2;   b^2;
c=b.^-1;  c=b^-1;  
c=b;

%Assignments using functions
a=zeros(2,2);  a=ones(2,3);
a=ones(3,3);

%Scalar functions (element by element)
abs(b);
round(b);
sin(b);   cos(b);
floor(b);  ceil(b);

%Vector functions (column by column)
max(b);   min(b);
sum(b);   mean(b);

%Matrix functions
size(b);  
A=reshape(1:12,3,4)

%Relations
c=(b==2) ;
c=(b>2 & b<=4) ;
c=(b<2 | b<=4) ;
c=(b~=a);

%Sub-Matrices 
a=[1:12];
b=reshape(a,3,4);
c=b(:); max(b(:));
b(2,1);
b(:,2);
b(2,:);
b(2:3,1:2:4);  b([2 3],[1 3]);
c=(b>2 & b<4);  sum(c(:))

% control flow:  IF
i = 3;
if i < 5
   disp('Small');
elseif i==5
   disp('Medium');
else
   disp('Big');
end;

% control flow:  FOR
for (i=10:-2:0)
   i
end;

% control flow:  WHILE
i = 1;
while i<10
   i
   i = i+1;
end;

% I/O
disp('Hello')
s = input('How Many?');

disp(['Hello' s]);
fprintf('Good %4d\n',s);


% graphics
plot(sin([0:0.01:1].*2.*pi));
plot([0:0.01:1].*2.*pi,sin([0:0.01:1].*2.*pi));
bar([1:10]);

%Images
im=readImage('lena.tif');
size(im)
showImage(im);
putImage(im);
writeImage(im,'foo.tif');

%Functions and scripts
A=reshape(1:12,3,4);

n=ent_num(A,5,7);
[a,b]=ent_num_pos(A,5,7);

