How do I make function which gets as input arguments matrix of chars work?
Show older comments
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
Accepted Answer
More Answers (1)
Kevin Phung
on 25 Jan 2019
Use curly brackets.
example:
case {'GUU', 'GUC', 'GUA', 'GUG'}
aminoacids{m} = 'Val';
I also dont think you need the line aminoacids=aminoacids
1 Comment
Drugie Konto
on 25 Jan 2019
Categories
Find more on Genomics and Next Generation Sequencing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!