Kevin's Answer Is Correct Of Course,
But If that Was The Problem You Were Facing You Would Have Had A Different Error About Indexing Mismatch or SWITCH expression must be a scalar or a character vector.
I suspect you called the translation function with a character vector input, something like:
a = translation('GCUGAC')
the problem is that when you test the value at index m of that codons vector you get a single character 'G', 'C', 'U' or 'A' which is never equal to any of the sequences in your switch case.
what you need to do is send the codon sequence as a cell array of character vectors:
a = translation({'GCU' 'GAC'})
then you need to index that inside the loop with curly bracers like kevin said:
and the output should also be a cell array proobably (like kevin suggested)
moreover, it's always a good idea to add a default value for output arguments, add
just before the loop.
Best Answer