## An example octave file

				# define matrices
A = [ 2 -1 ;
      -1 2 ] ;
				# and vectors
v = [ 1 ;
      1 ]   ;
				# * means matrix-multiply
disp(" A*v = " )
A*v 

u = [ 3;
     -3 ]   ;

disp(" A*u = " ) 
disp(A*u)
				# matrix inverse
B = inv(A)
disp(" B*u = " ) ; 
B*u
				# rows are separated by ";" 
N = [v ; u ] 
				# columns are separated by ","
M = [ v , u ]
disp("B*M = ")
B*M

more off ; ## disables the page-scrolling behaviour
ans = input( " type in a number " ) ;
printf( "you typed %d\n", ans ) ;

B = [ 1 2 3 4 5 ;  11 12 13 14 15  ; 21 22 23 24 25 ]
## to access a range of a matrix, use A(a:b, c:d)
##  to get the whole range of a column or row  use ":"
C = B(1:2 , 2:4)
D = B(:, 2:4 )

ans = input( " ready? " ) ;

N=9;
disp(" Now we call a function defined in file springs.m ")
[S,SI] = springs(N) 

disp( " The inverse of the spring matrix shows the " )
disp( " response of the system to a unit force at each point")
plot(SI * 10 ) ; ## plot, given a matrix, plots each column as a graph with
## the row-number as the x-axis

ans = input( " ready? " ) ;

disp (" now find the eigenvectors (E) and eigenvalues (V) " ) 
[E,lambda] = eig(S)
disp (" here are the eigenvalues as a vector " ) 
v = diag(lambda)
sv = sort( v ) ;
plot ( sv );
figure(2);

## here are the first two eigenvectors
e1 = E(:,1) 
e2 = E(:,2) ;
plot ( E(:,1:2 ) ) 

## To get help on a function 'eig', type 
##    help eig
## To get elementwise multiplication
##    or elementwise division, use .* and ./
