function matread = readr(fh,nrows); % matread=readr(fh,nrows) Reads nrows from a Gauss data set % which was opened with open (not fopen) command global gaussfh; % gauss file handle info curpos=ftell(fh); % put current pos in temp var. currow=curpos/(gaussfh(fh,1)*gaussfh(fh,2)); % convert cur. pos to cur row tnrows=rowsf(fh); % obtain # of rows in file netr=nrows*gaussfh(fh,1); % number of elements to read if gaussfh(fh,2)==1; precstr='uchar'; % assume unsigned character elseif gaussfh(fh,2)==2; precstr='uint16'; % assumed unsigned integer 16 bit elseif gaussfh(fh,2)==4; precstr='float32' % assume 32 bit floating elseif gaussfh(fh,2)==8; precstr='float64' % assume 64 bit floating end; if nrows>(tnrows-currow); nrows=tnrows-currow; end; [matread,nread]=fread(fh,netr,precstr); matread=reshape(matread,gaussfh(fh,1),nrows)'; return;