rle2

PURPOSE ^

'RLE2' find the zeros in a vector, and then substitude them by

SYNOPSIS ^

function [aa,longit]=rle2(b)

DESCRIPTION ^

'RLE2' find the zeros in a vector, and then substitude them by
 a flag.

 USE: [v_no_zeros,num_ceros]=rle2(vector_with_zeros);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 %'RLE2' find the zeros in a vector, and then substitude them by
0003 % a flag.
0004 %
0005 % USE: [v_no_zeros,num_ceros]=rle2(vector_with_zeros);
0006 %
0007 
0008 function [aa,longit]=rle2(b)
0009 
0010 [x,y]=size(b);
0011 
0012 if x>y
0013     b=b';
0014 end
0015 
0016 aaa=(b==0);
0017 
0018 c=[aaa 0]-[0 aaa];
0019 ini=find(c==1);
0020 fin=find(c==-1);
0021 longit=fin-ini;
0022 nn=length(ini);
0023 aa=[];
0024 g=[1 fin];
0025 for i=1:nn,
0026    aa=[aa b(g(i):ini(i)-1) 0];
0027    [nn i];
0028 end
0029 if nn>0
0030    aa=[aa b(fin(length(fin)):length(b))];
0031 else
0032    aa=b;
0033    longit=0;
0034 end
0035

Generated on Fri 07-Mar-2014 13:29:20 by m2html © 2005