I still recommend what I wrote in my previous reply.

Nevertheless don’t know whether this would do what you need or whether it will work. Use polyfit separately on the two regions of xx to fit the quadratic and linear approximations, but do so outside CVX, i.e., just use polyfit as intended in MATLAB. Then take the two fitted pieces, and implement them in CVX via use of Big M modeling to define the piecewise function (if xx <=… then fitted_quadratic. else fitted_linear). https://www.fico.com/en/resource-download-file/3217 will show you how to do that… I don;t understand what you are doing with `Jsunhao`

, so I don’t know if it will work out and even be accepted by CVX, but it looks to me like it won’t work.