How do I make function which gets as input arguments matrix of chars work?
이전 댓글 표시
I am trying to write function which converts RNA codons into amino acids. The codons is matrix of chars for example 10x3. 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';
end
end
aminoacids = aminoacids;
end
채택된 답변
추가 답변 (1개)
Kevin Phung
2019년 1월 25일
Use curly brackets.
example:
case {'GUU', 'GUC', 'GUA', 'GUG'}
aminoacids{m} = 'Val';
I also dont think you need the line aminoacids=aminoacids
카테고리
도움말 센터 및 File Exchange에서 Sequence Alignment에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!