Index1.m

From Pnb
Revision as of 15:21, 5 August 2010 by 128.111.101.185 (talk) (Created page with '<pre> function [indexing,merloc,depthloc] = index1(lcdin) %created by Erik Stassinos %3/16/10 %this function will scan through the lcd file and determine the column %position in …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
function [indexing,merloc,depthloc] = index1(lcdin)
%created by Erik Stassinos
%3/16/10
%this function will scan through the lcd file and determine the column
%position in the data field to operate on as well as locations of up and
%down cast points

lcd = lcdin; %= 'za110211a.lcd'
fid = fopen(lcd);

%---------------------loop1------------------------processed check
while feof(fid) ~= 1

    checkline = fgets(fid);
    if strncmp(checkline,'bbopdespike',11) ==1
       disp('this file has already been despiked')
       disp('exiting')
       break
    end
end
frewind(fid)
%----------------------endloop1-----------------end of processed check       

%-----------------------loop2--------------location for index/time/depth
 for i = 1:50   
    line = fgets(fid);
        if strncmp(line,'castid',6) == 1
            intoloop = ftell(fid);
            count = 0;
            while strncmp(fgets(fid),'<sampled',8) ~= 1
               pos = ftell(fid);
                count = count + 1;
            end
             sprintf('%s %d %s','there are',count,'casts') 
            fseek(fid,intoloop,-1);
             for t= 1:count
                 d= fgets(fid);
             n1(t,:) = textscan(d,'%*s %f %f %f');
        
             end
             break 
        end
 end
  % n1(1,1)   
%-------------------endloop2--------------end location for index/time/depth   

indexing(:,1) = n1(:,1);
merloc(:,1) = n1(:,2);
depthloc(:,1) = n1(:,3);

index1