www.pudn.com > Patternrecognition.rar > sep.m, change:2009-04-11,size:1658b


 function [xnrSize,xntSize,xnrIndex,xntIndex,xnr,xnt] = sep(x,dem,xIndex,rfa,sizepre) 
            
 xntSize=double(int16(sizepre*rfa)); xnrSize=sizepre-xntSize; 
 xnt=zeros(xntSize,dem); xnr=zeros(xnrSize,dem); 
 xntIndex=zeros(xntSize,1); xnrIndex=zeros(xnrSize,1); 
 
 i=1; 
 while(i<=xntSize) 
     rmn=xIndex(uint16((rand(1,1)*sizepre)+1),1); 
     quitflag=1; 
     for j=1:i 
         if(xntIndex(j,1)==rmn) 
             quitflag=0; 
             break; 
         end; 
     end; 
     if(quitflag) 
         xntIndex(i,1)=rmn; 
         i=i+1; 
    end; 
end; 
xntIndex=sort(xntIndex); 
 
xntIndexInx=zeros(xntSize,1);j=1; 
for i=1:xntSize 
    while(xntIndex(i,1)~=xIndex(j,1)) 
        j=j+1; 
    end; 
    xntIndexInx(i,1)=j; 
end; 
i=1;j=1;randex=0;randpr=xntIndexInx(j,1); 
while(i<=xnrSize) 
    if(j~=1) 
        randex=randpr; 
        if(j~=xntSize+1) 
            randpr=xntIndexInx(j,1); 
        else 
            randpr=sizepre+1; 
        end; 
    end; 
    randdelt=randpr-randex; 
    while(randdelt>1) 
        xnrIndex(i,1)=xIndex((randpr-randdelt+1),1); 
        randdelt=randdelt-1; 
        i=i+1; 
    end; 
    j=j+1; 
end; 
 
if(dem==2) 
    for i=1:xnrSize  
        xnr(i,1)=x((xnrIndex(i,1)),1); xnr(i,2)=x((xnrIndex(i,1)),2); 
    end; 
    for i=1:xntSize 
        xnt(i,1)=x((xntIndex(i,1)),1); xnt(i,2)=x((xntIndex(i,1)),2); 
    end; 
end; 
 
if(dem==3) 
    for i=1:xnrSize 
        xnr(i,1)=x(xnrIndex(i,1),1); xnr(i,2)=x(xnrIndex(i,1),2); xnr(i,3)=x(xnrIndex(i,1),3); 
    end; 
    for i=1:xntSize  
        xnt(i,1)=x(xntIndex(i,1),1); xnt(i,2)=x(xntIndex(i,1),2); xnt(i,3)=x(xntIndex(i,1),3);  
    end; 
end;