partie 1 :Compression :

 

La fonction obt_chaine

function yy=obt_chaine(o,cc,p,typevir)

%Si o=5,cc='a',p=1 et typevir=0 cette matrice donnera le code suivant :

% a1,a2,a3,a4,a5

% typevir=0 > ','

% typevir=1 ou autre > ';'

clear yy;

if p>o

   erreur('p doit être < o');

end % end if

%Déterminer le type de la virgule

x=p;pas=1;

  if typevir==0

  vir=',';

  else vir=';';

  end % end if

while x<=o

X=num2str(x);

LL=length(X);

   if x==o

yy(pas,:)=cc;

pas=pas+1;ii=1;

for ii=1:LL

yy(pas,:)=X(ii);

pas=pas+1;

end %end for

pas=pas+1;break;

   end % end if

yy(pas,:)=cc;

pas=pas+1;ii=1;

for ii=1:LL

yy(pas,:)=X(ii);

pas=pas+1;

end % end for 

pas=pas+1;yy(pas,:)=vir;

pas=pas+1;x=x+1; 

end % end while

yy=strcat(yy)';