下面是我自己的代码的
you.gender = input ('\n\n please enter your gender. (f/m/x)\n\n','s');
input1 = 'f';input2 = 'm';input3 = 'x'; % define the input answer
s1 = {input1,input2,input3}; % 3 input strings into the cell
cig1 = strcmp(you.gender,s1); % compare the input and the right answer
cig2 = isempty(you.gender); % if it is an empty input
cig12 = xor(cig1,cig2); % 0 + 1
while cig12 == 1 % if no correct answer(1),then input again
fprintf('\n\n Error! Invalid input!\n\nPlease enter ''f'' for female, ''m'' for male, ''x'' for third sex.\r\n');
you.gender = input ('\n\n please enter your gender. (f/m/x)\n\n','s');
if cig12 == 0
break
end
end % end, when it's the correct input
下面是 matlab中document的 xor 的解释