MATLAB: Help with if construct error

dispif constructoutputscript

I created this script for the user to input either English, Literature, Astronomy or History and in the command window it will accept English and History but not the other two, any help?
x=input('Please choose of of the following electives\n English\n History\n Astronomy\n Literature\n: ','s');
if x=='English'
disp('English has been selected.');
elseif x=='History'
disp('History has been selected.');
elseif x=='Astronomy'
disp('Astronomy has been selected.');
elseif x=='Literature'
disp('Literature has been selected.');
else
disp('Invalid choice selected.');
end

Best Answer

Use strcmp (or strcmpi) to compare strings, not ==
if strcmp(x, 'English')
...
Another option would be to use a switch statement instead of if
switch x
case 'English'
...
case 'History'
...
...
end