MATLAB: If, or or or or or

if or switch case

I'm just wondering if Matlab can string together "or" statements? The current code for a simple menu is using
userinput = input("Select 1,2,3,4 and press enter: ")
if X == 1
disp(stuff)
if X == 2
disp(stuff)
% etc. this is just an example
end
Seems like you should be able to use if X=(1||2||3||4) to avoid the multiple lines of code. Then:
if X = (1||2||3||4)
Y= sprintf ("You selected: ", userinput)
disp(Y)
else
disp("That was not a choice")
end
We're on to using C++ now so I'm thinking along the lines of
cout <<"You seleceted"<< variable<< endl;
This is probably better done as a switch case but I was thinking about booleans when I started to try this.

Best Answer

It can, but you have to be a little more specific about it
if X == 1 || X == 2 || X == 3 || X == 4