Hs6 split.m
Jump to navigation
Jump to search
function hs6_split() %Created by Erik Stassinos 5/26/2010 %This function takes the input single lcd and then slits it into up and %downcast matricies line =0; h1=0; id = fopen('list_hs6') if id == -1 disp('cannot find hs6 list file') return end while feof(id) ~=1 tu = fgets(id); h1 = h1+1; end frewind(id) for i = 1:h1%%%%%%%%%%%%%%%%%%%%%%%%%%%% %clear h1; line =0; r = fgets(id); length(r); t = textscan(r,'%s'); p = char(t{1,:}) [in,mer,dep] = index1(p); in{1}; in{2}; in{3}; in{4}; m = strrep(p,'.lcd','.datmat'); mat = load(m,'.ASC'); width = length(mat(1,:)); %format long clear ij clear downcastmatrix clear upcastmatrix for ij = in{1}:1:in{2}; downcastmatrix(ij-(in{1}-1),:) = mat(ij,1:width); %starts from 1 and goes to in2 end for r = in{3}:in{4}; upcastmatrix(r-(in{3}-1),:) = mat(r,1:width); end dlmwrite(strcat(m,'.1'),downcastmatrix,'delimiter',' ','precision',6); dlmwrite(strcat(m,'.2'),upcastmatrix,'delimiter',' ','precision',6); name1 = strrep(p,'.lcd','.lcd.1') name2 = strrep(p,'.lcd','.lcd.2') nfile1 = fopen(strrep(p,'.lcd','.lcd.1'),'w+'); nfile2 = fopen(strrep(p,'.lcd','.lcd.2'),'w+'); oglcd = fopen(p) while strncmp(line,'<data>',6) ~= 1 if strncmp(line,'<data>',6) == 1 break end line = fgets(oglcd) fprintf(nfile1,'%s',line); fprintf(nfile2,'%s',line); end dn = fopen(strcat(m,'.1'),'r'); up = fopen(strcat(m,'.2'),'r'); for dc = 1:length(downcastmatrix(:,1)) down = fgets(dn); fprintf(nfile1,'%s',down); end for uc = 1:length(upcastmatrix(:,1)) upc = fgets(up); fprintf(nfile2,'%s',upc); end fprintf(nfile1,'%s\n','<filters_used>') fprintf(nfile2,'%s\n','<filters_used>') %=====update list_hs6====== h = i*2 r = h-1 newl(r,:) = name1; newl(h,:) = name2 end dlmwrite('list_hs6_s',newl,''); fclose all