function calfile=read_drftcfg(file_loc,dname) fid = fopen([file_loc 'cfg\drifter.cfg']); %burn the header X = '#'; while strncmp(X,'#',1) X=fgetl(fid); end k=0; while ~feof(fid) X=fgetl(fid); if strncmp(X,dname,length(dname)) X=fgetl(fid); while ~isempty(X) if strncmp(X,'TIME',4) k = k+1; ind = findstr(X,','); year = str2num(X(ind-4:ind)); jday = str2num(X(ind+1:end)); calfile.times(k)=jul2date(jday,year); else if ~isfield(calfile,'instruments') calfile.instruments = struct([]); end ind = findstr(X,':'); inst_type = X(1:ind-1); inst_val = X(ind+2:end); calfile.instruments = setfield(calfile.instruments,{k},inst_type,inst_val); end X=fgetl(fid); end end end