function x = qread2 % QREAD2 - Read /Dropbox/francisco/mbari.dat % Brian Schlining % 29 Jan 1999 FileName = 'j:\Francisco\mbari.dat'; fid = fopen(FileName,'rt'); BytesInHeader = 118; % Need to reposition the file pointer %========================================================== % Figure out roughly how many rows of data are in the file %========================================================== sByte = ftell(fid); % Get current position (in bytes) fseek(fid,0,'eof'); % go to the end of the file fByte = ftell(fid); % Get the position in Bytes BytesOfData = fByte - sByte; fseek(fid,BytesInHeader + 2,'bof'); % Rewind back to the original position + 1 line numRows = floor(BytesOfData/BytesInHeader); numCols = 13; x = ones(numRows,numCols)*NaN; n = 0; while ~feof(fid) s = fgetl(fid); n = n + 1; a = sscanf(s,'%f')'; if ~isempty(a) x(n,:) = a; end end fclose(fid); x = excise(x); i = find(x == 999.999); x(i) = NaN; x(:,14) = datnum(x(:,4)+1900,x(:,2),x(:,3));