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