# I have few questions regarding string. I have applied Run Length Encoding on a large string. But at the output I am getting some unwanted symbols. why it is so?

1 view (last 30 days)

Show older comments

function y = estring(str)

len = numel(str); %65536

i = 0;

count = zeros(1,len);

y=[];

while( i<len )

j=0;

count(i+1) = 1;

while( true )

j = j + 1;

if( i+j+1 > len )

break;

end

if( str(i+j+1)==str(i+1) )

count(i+1) = count(i+1) + 1;

else

break;

end

end

if false

a=str(i+1);

length(a);

y = [y a];

i = i + 1;

else

a=str(i+1);

b=count(i+1);

y =[y a b];

i = i + b;

if(count==1)

y=[y a b]

end

end

end

##### 1 Comment

### Answers (1)

Walter Roberson
on 12 May 2015

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!