RING=esrf(); ringpara(RING) indS=find( atgetcells( RING, 'Class', 'Sextupole' )); s00=findspos(RING, 1:length(RING)+1); [bd, par]=atx(RING,0,1:length(RING)); emits=par.modemittance; RING1 = RING; %%%%% misalign sextupoles to represent machine imperfections rng(123456); dxs = 100e-6 * randn([length(indS),1]); dys = 100e-6 * randn([length(indS),1]); RING1=atsetshift( RING1, indS, dxs, dys); [bd1, par1]=atx(RING1,0,1:length(RING1)); emits1=par1.modemittance; fprintf('%.4e ',emits1);fprintf('\n'); nlen=length(RING1); nspace=20; results=zeros([length(1:nspace:nlen), 7]); for ind = 1 : nspace : nlen %%%% rotate and start the lattice at ind-th element RING2 = [ RING1(ind:end,1); RING1(1:ind-1,1)]; [bd2, par2]=atx(RING2,0,1:length(RING2)); emits2=par2.modemittance; demitsratio=(emits2-emits1)./emits1; results((ind-1)/nspace+1, :) = [s00(ind), demitsratio, emits2]; fprintf('%.4e ',results((ind-1)/nspace+1, :));fprintf('\n'); end figure(1); plot(results(:,1),results(:,2),'b*'); hold on; plot(results(:,1),results(:,3),'ro'); legend('dex/ex0','dey/ey0'); save('./esrf_emits.txt','results','-ascii');