How do I check that my input doesn't have incorrect characters?

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)

all(ismember(str, 'acgu'))
or
isempty( setdiff(str, 'acqu') )
test=0
while test==0
str=input('enter dtring','s')
q=regexp(str,'[acgu]')
test=numel(q)==numel(str)
end

This question is closed.

Asked:

on 25 Mar 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!