Matlab will compare each character of both strings. If one string is longer than the other one, there is nothing to compare and it will throw an error. You can bypass this by forcing the user to repeat the input until he gives a valid input:
valid = {'f0', 'f1'}
a = input('Please type f0 or f1: ' , 's');
while not(ismember(a, valid)) %// or: while not(any(strcmp(a, valid)))
a = input('Please really type f0 or f1: ' , 's');
end
The user will be asked to really input 'f0' or 'f1'.
As an alternative, you can consider to compare the strings with strcmp()
:
if strcmp(a, 'f0')
%// something
elseif strmpc(a, 'f1')
%// something else
else
disp('Please enter f0 or f1 only');
end