MATLAB: Problem with using && operator in if conditional statement with array involved

conditional statementif statement with arrayslogical operator

i want to use if statement such that if ((x_value==645:650||730:735||815:820||900:905||980:985||1070:1075||1155:1160||1240:1145||1325:1330||1410:1415||1495:1500||1580:1585)&&(y_value==225:230)) out= S(1); end
OR
xx=[645:650,730:735,815:820,900:905,985:990,1070:1075,1155:1160,1240:1245,1325:1330,1410:1415,1495:1500,1580:1585]; yy=[225:230;275:280;325:330;375:380];
if ((x_value==xx)&& y_value==(yy(1,:))) out=S(1) end
but it gives error
Operands to the and && operators must be convertible to logical scalar values.
what is wrong with my code ??

Best Answer

Use ISMEMBER to check if x_value is an element of your set of desired outcomes.
x = 5;
if ismember(x, [1 3 5 7 9])
disp('First trial, odd number less than 10!');
end
x = 2;
if ismember(x, [1 3 5 7 9])
disp('Second trial, odd number less than 10!');
end