0001 function varargout = fitchrom2(newchrom, sextfam1, sextfam2, varargin);
0002
0003
0004
0005
0006 global THERING
0007
0008
0009 newchrom = newchrom(:);
0010 deltaS = 1e-5;
0011 deltaP = 1e-8;
0012
0013
0014 S1I = findcells(THERING,'FamName',sextfam1);
0015 S2I = findcells(THERING,'FamName',sextfam2);
0016 InitialS1 = getcellstruct(THERING,'PolynomB',S1I,3);
0017 InitialS2 = getcellstruct(THERING,'PolynomB',S2I,3);
0018
0019
0020
0021 [ LD, InitialTunes] = linopt(THERING,0);
0022 [ LDdP, ITdP] =linopt(THERING,deltaP);
0023
0024 InitialChrom = (ITdP-InitialTunes)/deltaP;
0025
0026 TempTunes = InitialTunes;
0027 TempChrom = InitialChrom;
0028 TempS1 = InitialS1;
0029 TempS2 = InitialS2;
0030
0031 for i=1:5
0032
0033
0034 THERING = setcellstruct(THERING,'PolynomB',S1I,TempS1+deltaS,3);
0035 [LD , Tunes_dS1 ] = linopt(THERING,0);
0036 [LD , Tunes_dS1dP ] = linopt(THERING,deltaP);
0037
0038 THERING = setcellstruct(THERING,'PolynomB',S1I,TempS1,3);
0039 THERING = setcellstruct(THERING,'PolynomB',S2I,TempS2+deltaS,3);
0040 [LD , Tunes_dS2 ] = linopt(THERING,0);
0041 [LD , Tunes_dS2dP ] = linopt(THERING,deltaP);
0042 THERING = setcellstruct(THERING,'PolynomB',S2I,TempS2,3);
0043
0044
0045 Chrom_dS1 = (Tunes_dS1dP-Tunes_dS1)/deltaP;
0046 Chrom_dS2 = (Tunes_dS2dP-Tunes_dS2)/deltaP;
0047
0048 J = ([Chrom_dS1(:) Chrom_dS2(:)] - [TempChrom(:) TempChrom(:)])/deltaS;
0049 Jinv = inv(J);
0050
0051 dchrom = (newchrom(:) - TempChrom(:));
0052 dS = Jinv*dchrom;
0053
0054 TempS1 = TempS1+dS(1);
0055 TempS2 = TempS2+dS(2);
0056
0057 THERING = setcellstruct(THERING,'PolynomB',S1I,TempS1,3);
0058 THERING = setcellstruct(THERING,'PolynomB',S2I,TempS2,3);
0059
0060 [ LD, TempTunes] = linopt(THERING,0);
0061 [ LD, TempTunesdP] = linopt(THERING,deltaP);
0062 TempChrom = (TempTunesdP-TempTunes)/deltaP;
0063
0064
0065 end