function y=f(x) if x<=2 y=0.5*x; elseif x>6 y=0.5; else y =1.5-0.25*x; end