Write a function called DNAcomplement that consumes a set of letters as a charac
ID: 3625397 • Letter: W
Question
Write a function called DNAcomplement that consumes a set of letters as a character array that form a DNA sequence such as 'gattaca' . The function will produce the complement of the sequence so that a 's become t 's, g ' s become c 's, and vice versa. The string 'gattaca' would therefore become 'ctaatgt' . You may assume that all the letters in the sequence will be lowercase and that they will all be either a, t, g, or c. Note: You may be tempted to use iteration for this problem, but you don't need it.Explanation / Answer
//FileName: DNAcomplement.m function convertedText = DNAcomplement (text,n)convertedText=ones(1,n);
for i=1 : n
if text(i) == 'a'
convertedText(1,i) ='t';
else if text(i) == 'g'
convertedText(1,i) = 'c';
end
end
end >> convertedText =DNAcomplement('gatacca',7);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.