function [data]=read_skiplines(name,ncol)
%
% USE: [data]=read_skiplines(name,ncol)
%
% skips leading lines with '#' on first position.
% then reads the remainder in column format, with 'ncol'
% columns.
% this is usefule for reading 'gnuplot' data files which have 
% some header lines.
%
fid=fopen(name);
sprintf('opened file: %s',name)
%
str1='#';
%
iline=0;
while 1
  iline=iline+1;
  tline = fgetl(fid);
  %sprintf('%s ',tline)
  if(~strncmp(tline,'#',1) & iline>1)
    break
  end;
end
sprintf('data starts at line %d',iline)
%
data1=sscanf(tline,'%g',[ncol,inf])';
%
%now: read the rest in column format:
data=fscanf(fid,'%g',[ncol,inf])';
%
data=[data1; data];
fclose(fid);
