0001 function out=extract_obslog(file,string,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 out=[];
0021 fprintf('Number of inputs = %d\n', nargin)
0022
0023 if nargin ==2
0024 disp('Using the entire file-no time interval')
0025 else if nargin ==4
0026 disp('Using the time interval')
0027 disp(varargin(1))
0028 disp('TO')
0029 disp(varargin(2))
0030 else
0031 error('Not correct number of arguments: Either call this function with 2 arguments or with 4 arguments- \n See help extract_obslog for details')
0032 end
0033 end
0034
0035 if(nargin==4)
0036 time_start=datevec(varargin(1),'dd-mmm-yyyy:HH:MM:SS');
0037 time_end=datevec(varargin(2),'dd-mmm-yyyy:HH:MM:SS');
0038 tstart_num=datenum(time_start);
0039 tend_num=datenum(time_end);
0040 end
0041 fid = fopen(file,'r');
0042 i=0;
0043 while 1
0044 tline = fgetl(fid);
0045 if ~ischar(tline), break, end
0046
0047 try
0048
0049 pat = '\s\s\s';
0050 tline;
0051 string;
0052 t=regexp(tline, pat,'split');
0053 i;
0054 t=regexp(tline, pat,'split');
0055
0056
0057 a=strfind(tline,string);
0058
0059
0060 if a~[];
0061
0062
0063
0064
0065
0066 if nargin ==4
0067 time_startfile=datevec(t{1},'dd-mmm-yyyy:HH:MM:SS');
0068
0069 tstart_filenum=datenum(time_startfile);
0070 try
0071 time_endfile=datevec(t{2},'dd-mmm-yyyy:HH:MM:SS');
0072 tend_filenum=datenum(time_endfile);
0073 catch
0074 display('No end data')
0075 end
0076
0077
0078 if (tstart_filenum>tstart_num)
0079 i=i+1;
0080 out{i,1}=t{1};
0081 out{i,2}=t{2};
0082 out{i,3}=t{3};
0083 end
0084 else if nargin==2
0085
0086 i=i+1;
0087
0088
0089
0090 end
0091 end
0092 end
0093 catch
0094 disp('Error');
0095 end
0096 end
0097
0098 ST = fclose(fid);