0001 function [s,e]=group(ind)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 s=[];
0016 e=[];
0017
0018 f=find(ind==1);
0019 cnt=1;
0020 if (~isempty(f))
0021 dif=diff(f);
0022 ff=find(dif>1);
0023 if (isempty(ff))
0024 s(cnt)=f(1);
0025 e(cnt)=last(f);
0026 cnt=cnt+1;
0027 else
0028 for j=1:(length(ff)+1)
0029 if (j==1)
0030 s(cnt)=f(1);
0031 e(cnt)=f(ff(j));
0032 elseif (j==(length(ff)+1))
0033 s(cnt)=f(ff(j-1)+1);
0034 e(cnt)=last(f);
0035 else
0036 s(cnt)=f(ff(j-1)+1);
0037 e(cnt)=f(ff(j));
0038 end
0039 cnt=cnt+1;
0040 end
0041 end
0042 end
0043
0044 s=sort(s);
0045 e=sort(e);
0046