2<t2<4 is parsed as ((2<t2)<4). The 2<t2 part returns 0 (false) or 1 (true) and then <4 part compares that 0 or 1 to <4, which is always true. The fix is:
S2 = [ sin( 2*pi*5*t2( t2<=2 ) ), sin( 2*pi*10*t2( 2<t2 & t2<4 ) ),sin( 2*pi*15*t2( t2>4 ) ) ];
By the way: is there a reason that you want the sample at t2 == 4 exactly to be omitted ?