function f=loadfile(fname,type,length,offset);
% f=loadfile(fname,type,length,offset);
% napr.: sII=loadfile('c:\data\cse\w001.II','short',5000,0);
% Reads binary data from the specified file and writes it into matrix A.
% The type argument controls the number of bits read for each value
% and the interpretation of those bits as character, integer or floating
% point values.  Any of the following strings, either the MATLAB
% versions, or their C or Fortran equivalents, may be used.
%
% 	    MATLAB    C or Fortran      Description
% 	    'char'    'char'            character,  8 bits
% 	    'schar'   'signed char'     signed character,  8 bits
% 	    'short'   'short'           integer,  16 bits
% 	    'int'     'int'             integer,  16 or 32 bits
% 	    'long'    'long'            integer,  32 or 64 bits*
% 	    'float'   'float'           floating point,  32 bits
% 	    'double'  'double'          long floating point,  64 bits
% 	    'uchar'   'unsigned char'   unsigned character,  8 bits
% 	    'ushort'  'unsigned short'  unsigned integer,  16 bits
% 	    'uint'    'unsigned int'    unsigned integer,  16 or 32 bits
% 	    'ulong'   'unsigned long'   unsigned integer,  32 bits
% 	
% 	    'char'    'char*1'          character,  8 bits
% 	    'float32' 'real*4'          32 bit floating point
% 	    'float64' 'real*8'          64 bit floating point
% 	    'int8'    'integer*1'       integer, 8 bits.
% 	    'int16'   'integer*2'       integer, 16 bits.
% 	    'int32'   'integer*4'       integer, 32 bits.
% 	              'integer*8'       integer, 64 bits.**
% 	     'intN'                     signed integer, N bits wide
% 	     'uintN'                    unsigned integer, N bits wide
%	
% 	     N represents any value between 1 and 32.
% 	     * 64 bits on DEC alpha
% 	     ** available on DEC alpha only


ff=fopen(fname,'r');
fseek(ff,offset,'bof');
  
f=fread(ff,length,type);
f=f';
fclose(ff);
