image thumbnail
from Kirchhoff Vortex Contour Dynamics Simulation by Travis Mitchell
Contour dynamics simulation of an elliptical vortex in 2D inviscid and incompressible flow

loadAscii(filename)
function a = loadAscii(filename)
%
%  File of unknown origin

fid = fopen(filename);
if fid==-1
    error([filename ': File does not exist']);
end
numlines = 0;
try
while( 1 )
tline = fgetl(fid);
if ~ischar(tline), break, end
    numlines=numlines+1;
end
fseek(fid, 0, 'bof');
a = fscanf(fid,'%g',[numlines inf]);
[r c] = size(a);
% The next two steps are required since MATLAB reads the data in column major format
% and fscanf reads data in row major format
a = reshape(a,c,r);
a = a';
fclose(fid);
catch
    fclose(fid);
    error([filename ': Error while reading file']);
end

Contact us at files@mathworks.com