0001 function [lindata,avebeta,avemu,avedisp,nu,xsi]=atavedata_mod(ring,dpp,refpts,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 lr=length(ring)+1;
0016 if islogical(refpts)
0017 refs=[refpts(:);false(lr-length(refpts),1)];
0018 else
0019 refs=false(lr,1);
0020 refs(refpts)=true;
0021 end
0022 long=atgetcells(ring,'Length',@(elem,lg) lg>0) & refs(1:end-1);
0023 needed=refs | [false;long];
0024 [lind,nu,xsi]=atlinopt(ring,dpp,find(needed),varargin{:});
0025
0026 lindata=lind(refs(needed));
0027 avebeta=cat(1,lindata.beta);
0028 avemu=cat(1,lindata.mu);
0029 avedisp=cat(2,lindata.Dispersion)';
0030
0031 if any(long)
0032 initial=[long(needed(1:end-1));false];
0033 final=[false;initial(1:end-1)];
0034
0035 lg=initial(refs(needed));
0036 L=atgetfieldvalues(ring(long),'Length');
0037
0038 beta0=avebeta(lg,:);
0039 alpha0=cat(1,lind(initial).alpha);
0040 mu0=avemu(lg,:);
0041 disp0=avedisp(lg,:);
0042
0043 beta1=cat(1,lind(final).beta);
0044 alpha1=cat(1,lind(final).alpha);
0045 mu1=cat(1,lind(final).mu);
0046 disp1=cat(2,lind(final).Dispersion)';
0047
0048 L2=[L L];
0049 avebeta(lg,:)=betadrift(beta0,beta1,alpha0,L2);
0050 avemu(lg,:)=0.5*(mu0+mu1);
0051 avedisp(lg,[1 3])=(disp1(:,[1 3])+disp0(:,[1 3]))*0.5;
0052
0053 foc=atgetcells(ring(long),'PolynomB',@(el,polb) length(polb)>=2 && polb(2)~=0 && abs(polb(2))==max(abs(polb))) ;
0054 if any(foc)
0055 qp=false(size(long));
0056 qp(long)=foc;
0057 K=zeros(size(L));
0058 K(foc)=atgetfieldvalues(ring(qp),'PolynomB',{2});
0059 K2=[K -K];
0060 sel=false(size(avebeta,1));
0061 sel(lg)=foc;
0062 avebeta(sel,:)=betafoc(beta1(foc,:),alpha0(foc,:),alpha1(foc,:),K2(foc,:),L2(foc,:));
0063 avedisp(sel,[1 3])=dispfoc(disp0(foc,[2 4]),disp1(foc,[2 4]),K2(foc,:),L2(foc,:));
0064 end
0065 avedisp(lg,[2 4])=(disp1(:,[1 3])-disp0(:,[1 3]))./L2;
0066 end
0067
0068 function avebeta=betadrift(beta0,beta1,alpha0,L)
0069 gamma0=(alpha0.*alpha0+1)./beta0;
0070 avebeta=0.5*(beta0+beta1)-gamma0.*L.*L/6;
0071 end
0072
0073 function avebeta=betafoc(beta1,alpha0,alpha1,K,L)
0074 gamma1=(alpha1.*alpha1+1)./beta1;
0075 avebeta=0.5*((gamma1+K.*beta1).*L+alpha1-alpha0)./K./L;
0076 end
0077
0078 function avedisp=dispfoc(dispp0,dispp1,K,L)
0079 avedisp=(dispp0-dispp1)./K./L;
0080 end
0081
0082 end