% matrices 

format short g; echo on; 

% building vectors and matrices 
v = [1:2:8]
w = [ones(3,1); linspace(0,1,5)']
pause;

A = [1 1; 1 -1]
B = [zeros(2,1),  A; ... 
     rand(2,3)]
pause; 

% formatted printing
M = magic(4) 
fprintf(1,'%2d %2d %2d %2d \n',M)
pause;

% diagonals of matrices
diag(M,1) 
d = diag([1:3],-1)
diag(d)
pause;

echo off; format; 

