Home > lattice > atsbreak.m

atsbreak

PURPOSE ^

ATSBREAK Insert markers at given s positions in a lattice

SYNOPSIS ^

function [newring,refpts] = atsbreak(ring,sdata)

DESCRIPTION ^

ATSBREAK Insert markers at given s positions in a lattice

[NEWRING,REFPTS]=ATSBREAK(RING,SPOS) build a new lattice with breakpoints

RING:  AT structure
SPOS:  Poition of the desired breakpoints

NEWRING:   Modified AT structure
REFPTS:    Index of breakpoints

 See also ATINSERTELEMS ATSPLITELEM ATDIVELEM

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [newring,refpts] = atsbreak(ring,sdata)
0002 %ATSBREAK Insert markers at given s positions in a lattice
0003 %
0004 %[NEWRING,REFPTS]=ATSBREAK(RING,SPOS) build a new lattice with breakpoints
0005 %
0006 %RING:  AT structure
0007 %SPOS:  Poition of the desired breakpoints
0008 %
0009 %NEWRING:   Modified AT structure
0010 %REFPTS:    Index of breakpoints
0011 %
0012 % See also ATINSERTELEMS ATSPLITELEM ATDIVELEM
0013 
0014 mk=atmarker('xyzt');
0015 selem=findspos(ring,1:length(ring)+1);
0016 [sv,isort]=sort(mod(sdata(:)',selem(end)));
0017 ir=1;
0018 is=1;
0019 it=0;
0020 nr={};
0021 for ie=1:length(ring)
0022     if selem(ie+1) > sv(is)
0023         elem=ring{ie};
0024         for j=is:length(sv)
0025             if selem(ie+1) <= sv(j)
0026                 last=j-1;
0027                 break
0028             end
0029             last=j;
0030         end
0031         frac=(sv(is:last)-selem(ie))./elem.Length;
0032         is=last+1;
0033         it=it+1;
0034         nr{it}=[ring(ir:ie-1);atsplitelem(elem,frac,mk)]; %#ok<AGROW>
0035         ir=ie+1;
0036         if is > length(sv), break; end
0037     end
0038 end
0039 newring=cat(1,nr{:},ring(ir:end));
0040 refpts(isort)=find(atgetcells(newring,'FamName','xyzt'));
0041 refpts=reshape(refpts,size(sdata));
0042 end

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005