How do I check that my input doesn't have incorrect characters?
Info
This question is closed. Reopen it to edit or answer.
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?
Answers (2)
Walter Roberson
on 25 Mar 2013
Edited: Walter Roberson
on 25 Mar 2013
all(ismember(str, 'acgu'))
or
isempty( setdiff(str, 'acqu') )
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
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!