Fit a piecewise function

I believe it is a duplicate of Linear interpolation TH2