<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki-pnb.eri.ucsb.edu/index.php?action=history&amp;feed=atom&amp;title=Zcorr.m</id>
	<title>Zcorr.m - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki-pnb.eri.ucsb.edu/index.php?action=history&amp;feed=atom&amp;title=Zcorr.m"/>
	<link rel="alternate" type="text/html" href="https://wiki-pnb.eri.ucsb.edu/index.php?title=Zcorr.m&amp;action=history"/>
	<updated>2026-04-21T06:51:48Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>https://wiki-pnb.eri.ucsb.edu/index.php?title=Zcorr.m&amp;diff=216&amp;oldid=prev</id>
		<title>128.111.101.185: Created page with '&lt;pre&gt;  function  zcorr(scale,offset) %created by Erik Stassinos 3/3/10 %function to apply depth correction with slope and offset info from matlab %program createdepth    Dirname …'</title>
		<link rel="alternate" type="text/html" href="https://wiki-pnb.eri.ucsb.edu/index.php?title=Zcorr.m&amp;diff=216&amp;oldid=prev"/>
		<updated>2010-08-05T23:55:53Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;pre&amp;gt;  function  zcorr(scale,offset) %created by Erik Stassinos 3/3/10 %function to apply depth correction with slope and offset info from matlab %program createdepth    Dirname …&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function  zcorr(scale,offset)&lt;br /&gt;
%created by Erik Stassinos 3/3/10&lt;br /&gt;
%function to apply depth correction with slope and offset info from matlab&lt;br /&gt;
%program createdepth&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Dirname =   pwd;&lt;br /&gt;
pattern = fullfile(Dirname,'*.lcd'); %gets only lcd extensions&lt;br /&gt;
directory = dir(pattern);&lt;br /&gt;
clear i&lt;br /&gt;
%make sure only the ayymmdd.lcd files are counted&lt;br /&gt;
isz =0;&lt;br /&gt;
for i=1:size(directory)&lt;br /&gt;
name = directory(i).name;&lt;br /&gt;
%isz= strncmp(name,'z',1)&lt;br /&gt;
% if isz ==1&lt;br /&gt;
%     sprintf('There seem to be z corrected files already here; they will be ignored')&lt;br /&gt;
%     &lt;br /&gt;
%    break&lt;br /&gt;
% end&lt;br /&gt;
list_lcd(i,:) = name&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
if isz ~=1&lt;br /&gt;
    clear list_lcd&lt;br /&gt;
end&lt;br /&gt;
for p = 1:size(directory);&lt;br /&gt;
    if isz ~=1&lt;br /&gt;
       directory(p).name&lt;br /&gt;
    list_lcd(p,:) = directory(p).name&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
for j = 1:size(list_lcd)&lt;br /&gt;
    nlcd = strrep(list_lcd(j,:),'.lcd','.lcd'); %decided to create another file beacuse I have yet to figure out how to open original &lt;br /&gt;
    nlcd = strcat('z',nlcd);&lt;br /&gt;
    %lcd file for writing without leaving old stuff on the end or&lt;br /&gt;
    %completely erasing the lcd info so it cannot be modified uppon open&lt;br /&gt;
    id = fopen(nlcd,'w+') ;%new lcd file&lt;br /&gt;
    fid = fopen(list_lcd(j,:),'r'); %old lcd file to be erased&lt;br /&gt;
   T=1;&lt;br /&gt;
    &lt;br /&gt;
        for u = 1:500 %arbitrary amount just to go over the &amp;lt;data&amp;gt; position&lt;br /&gt;
            r = ftell(fid);&lt;br /&gt;
            line = fgets(fid);&lt;br /&gt;
            r3 = ftell(fid)  ;&lt;br /&gt;
                if strncmp(line,'1depth',6) ==1&lt;br /&gt;
                fseek(fid,r,-1);&lt;br /&gt;
                d = textscan(fid,'%s %n %n %n',1);&lt;br /&gt;
                d{1};&lt;br /&gt;
                d{2};&lt;br /&gt;
                dep = char(d{1});&lt;br /&gt;
                fprintf(id,'%s %d %5.5f %5.5f %d %d\n',dep,d{2},scale,offset,d{3},d{4});%)'%5.5f %n %n %n',d{:,1:4})&lt;br /&gt;
                %fprintf(id,'%5.5f %5.5f\n',offset,scale)&lt;br /&gt;
                r2 = ftell(id);&lt;br /&gt;
                  T = 30000000; %if T matches a line number it will skip the line that number matches&lt;br /&gt;
                  fseek(fid,r3,-1);&lt;br /&gt;
                end&lt;br /&gt;
                %so it doesn't write the same line twice  for 1depth condition&lt;br /&gt;
               if T ~=30000000 &lt;br /&gt;
               fwrite(id,line);&lt;br /&gt;
               end&lt;br /&gt;
                T = T+1 ;     &lt;br /&gt;
                if strncmp(line,'&amp;lt;data&amp;gt;',5) == 1;&lt;br /&gt;
                break&lt;br /&gt;
                end    &lt;br /&gt;
        end&lt;br /&gt;
            fseek(fid,r,-1);&lt;br /&gt;
                     &lt;br /&gt;
                     s = strrep(list_lcd(j,:),'.lcd','.datmatrix');&lt;br /&gt;
                     m = load(s);&lt;br /&gt;
                     a = (m(:,22));  &lt;br /&gt;
                     a(1,1);&lt;br /&gt;
                     format long e&lt;br /&gt;
                       anew = (a - offset)/(scale);&lt;br /&gt;
                       anew(1,1);&lt;br /&gt;
                        %test break for first time&lt;br /&gt;
                       m(:,22) = (anew);&lt;br /&gt;
                       nm = strrep(list_lcd(j,:),'.lcd','.zcal');&lt;br /&gt;
                       dlmwrite(nm,m,'delimiter',' ','precision',6);&lt;br /&gt;
                       mid = fopen(nm);&lt;br /&gt;
                       frewind(mid);&lt;br /&gt;
                   &lt;br /&gt;
                     for o = 1:length(m); %writes new matrix lines to file&lt;br /&gt;
                       mline =  fgets(mid);&lt;br /&gt;
                       fprintf(id,mline);&lt;br /&gt;
                     end&lt;br /&gt;
                           fprintf(id,'%s\n','&amp;lt;filters_used&amp;gt;');&lt;br /&gt;
                           fprintf(id,'%s %5.5f %5.5f','recal',scale, offset);&lt;br /&gt;
       newac9list(j,:) = nlcd;&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
fclose(fid);&lt;br /&gt;
fclose(id);&lt;br /&gt;
dlmwrite('list_ac9',newac9list,'');&lt;br /&gt;
sprintf('done with recal')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;[[zcorr]]&amp;lt;big&amp;gt;&lt;/div&gt;</summary>
		<author><name>128.111.101.185</name></author>
		
	</entry>
</feed>