I am trying to write function which converts RNA codons into amino acids. The codons is matrix of chars for example 10×3. There is still is an error output arguments "aminoacids" (and maybe others) not assigned during call to "translation". I don/t know how to fix it. Tried to by replacing aminoacids(m) with result(m) and then typing just above the end of the function "aminoacids=result" but it still doesn't work. Please help.
function [aminoacids] = translation(codons)for m = 1:length(codons)switch (codons(m)) case {'GCU', 'GCC', 'GCA', 'GCG'} aminoacids(m) = 'Ala'; case {'UGU', 'UGC'} aminoacids(m) = 'Cys'; case {'GAU', 'GAC'} aminoacids(m) = 'Asp'; case {'GAA', 'GAG'} aminoacids(m) = 'Glu'; case {'UUU', 'UUC'} aminoacids(m) = 'Phe'; case {'GGU', 'GGC', 'GGA', 'GGG'} aminoacids(m) = 'Gly'; case {'CAU', 'CAC'} aminoacids(m) = 'His'; case {'AUU', 'AUC', 'AUA'} aminoacids(m) = 'Ile'; case {'AAA', 'AAG'} aminoacids(m) = 'Lys'; case {'UUA', 'UUG', 'CUU', 'CUC', 'CUA', 'CUG'} aminoacids(m) = 'Leu'; case 'AUG' aminoacids(m) = 'Met'; case {'AAU', 'AAC'} aminoacids(m) = 'Asn'; case {'CCU', 'CCC', 'CCA', 'CCG'} aminoacids(m) = 'Pro'; case {'CAA', 'CAG'} aminoacids(m) = 'Gln'; case {'CGU', 'CGC', 'CGA', 'CGG', 'AGA', 'AGG'} aminoacids(m) = 'Arg'; case {'UCU', 'UCC', 'UCA', 'UCG', 'AGU', 'AGC'} aminoacids(m) = 'Ser'; case {'ACU', 'ACC', 'ACA', 'ACG'} aminoacids(m) = 'Thr'; case {'GUU', 'GUC', 'GUA', 'GUG'} aminoacids(m) = 'Val'; case 'UGG' aminoacids(m) = 'Trp'; case {'UAU', 'UAC'} aminoacids(m) = 'Tyr'; case {'UAA', 'UAG', 'UGA'} aminoacids(m) = 'Stop';endendaminoacids = aminoacids;end
Best Answer