As a replacement for what you have done here, I would suggest using ismember to find the triples that form valid codes. You can even use it to keep track of every marked position so you can see if you forgot to implement any triples.
amino_acid_chain = cellstr(reshape(neucleotide_string,3,[])');
L=false(size(amino_acid_chain));
library={{'E','GAA','GAG'};...
{'W','UGG'}};
for n=1:numel(library)
triplet=library{n}(2:end);
letter=library{n}(1);
L_current_code=ismember(amino_acid_chain,triplet);
amino_acid_chain(L_current_code)=letter;
L=L | L_current_code;
end
if any(~L)
error('some code was not implemented correctly')
end
Best Answer