using lsqcurvefit to fit piece-wise linear

290 Views Asked by At

I would like to use this function to fit piece-wise linearly to a set of data. Namely, I want to fit them with several linear segments.

Including other requirements, I would not want the segments are divided evenly along x-axis but are optimally divided along x-axis

My current problem is: I'm not sure if this MATLAB function support this. Also, if it does, how may I feed the function to function handle (MATLAB does not mention function handle if unlimit number of segments)

Thank you