Info
This question is closed. Reopen it to edit or answer.
How do I check that my input doesn't have incorrect characters?
1 view (last 30 days)
Show older comments
In this program, we ask people to input a three letter codon. This input must only have the letters a,c,g,u in it. How do I check that the rest of the letters are not in it?
0 Comments
Answers (2)
Walter Roberson
on 25 Mar 2013
Edited: Walter Roberson
on 25 Mar 2013
all(ismember(str, 'acgu'))
or
isempty( setdiff(str, 'acqu') )
0 Comments
Azzi Abdelmalek
on 25 Mar 2013
Edited: Azzi Abdelmalek
on 25 Mar 2013
test=0
while test==0
str=input('enter dtring','s')
q=regexp(str,'[acgu]')
test=numel(q)==numel(str)
end
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!