MATLAB: Evaluate whether a condition is met

conditionif

Hi all, I have to evaluate whether a condition is met: this is the basic method:
if a1 < b1 < a2
disp ('ok')
else disp ('error')
end
If I had n "b" and n+1 "a" I should write n if or is there a way to simplify it? if so how? thank you very much

Best Answer

Assuming size(a) is [1,n+1] and size(b) is [1,n]
if a(1:end-1)<b & b<a(2:end)