datain=input('enter the string in single quote with symbol $ as End of string =');%input data
lda=length(datain);dictionary=input('enter the dictionary in single quote(symbol used in string are to be included)=');%input dictionary
ldi=length(dictionary);%for i=1:ldi
%dictnew(i)={dictionary(i)};
%end
dictnew(1)=datain(1);s=dictnew(1);i=1;j=1;k=1;while datain(i)~= '$'c=datain(i); if c~='$' check=ismember(dictnew,c); if(check==0) if datain(i)=='$' break end dictnew(j+ldi)=datain(i); i=i+1; j=j+1; else s=datain(i+1); cat=strcat(c,s); check=ismember(dictnew,cat); if(check==0) if datain(i+1)=='$' break end dictnew(j+ldi)={cat}; i=i+2; j=j+1; else s=datain(i+2); cat=strcat(cat,s); if datain(i+2)=='$' break end dictnew(j+ldi)={cat}; i=i+3; j=j+1; end end endend
MATLAB: In lz78 what is “??? Error using ==> cell.ismember at 28” and “Error in ==> lz78 at 19”
dictnew(1)=datain(1)
Best Answer