[Edit: fix spelling.]
I agree with @John D'Errico that providing your data is an excellent idea. You say "I need to apply piecewise linearization to the model with X and Y together". You want the model to be additively separable: h(x,y)=f(x)+g(y), and you are OK with nonlinear f(x) and nonlinear g(y).
You can do it piecewise by defining ranges for one variable of the other, or both.
For example, define region boundaries for x: xb=[0,33,67,100]. Fit the data in each region separately:
H1=f1(x)+g1(y) fit it for the data (xb(1)<=x<xb(2), all y)
H2=f2(x)+g2(y) fit it for the data (xb(2)<=x<xb(3), all y)
H3=f3(x)+g3(y) fit it for the data (xb(3)<=x<xb(4), all y)
Or you could do it with bounds for y, instead of x. Or you could have ranges for both x and y. But that seems too obvious, so I doubt you want that. One drawback with the approach above is that the combined model will probably be discontinuous at the region edges.
If you want C0 continuity, you could map x and/or y in a piecewise continuous way to an intermediate variable, then fit the intermediate variable.
Example, using x only. x is mapped to xint, which varies in a continuous peicewise linear way from 0 to 1.The The mapping from x to xint is fully determined by 2 parameters: the horizontal and vertical coordinates (x1,xint1) of the breakpoint.
xint=xmapped(x,x1,xint1);
function xint=xmapped(x,x1,xint1)
xint(i)=xint1*(x(i)-min(x))./(x1-min(x));
xint(i)=xint1+(x(i)-x1).*(1-xint1)./(max(x)-x1);
plot(x,xint,'-bx'); grid on; xlabel('x'); ylabel('xint')
If you do not require that 0<xint1<1, then xint(x) could be a non-monotonic peicewise linear function of x, without adding any more adjustable parameters.
Use this approach to fit some nonlinear data.
xdata=[2:2:98]'; ydata=zeros(size(xdata)); N=length(xdata);
ydata(i)=100+10*sin(xdata(i)*pi/80);
ydata(i)=100-70*(exp((xdata(i)-80)/20)-1);
plot(xdata,ydata,'ok',MarkerSize=4,MarkerFaceColor='k');
grid on; xlabel('x'); ylabel('y')
Define the model. Note that the model is a quadratic equation, while the data is a half-cycle of a sinusoid connected to an exponential. That is a good reflection of real data, which doesn't come from our model equation.
myMod=fittype(@(a0,a1,a2,x1,xint1,x) a0+a1*xmapped(x,x1,xint1)+a2*xmapped(x,x1,xint1).^2);
Fit the model
f1 = fit( xdata, ydata, myMod,StartPoint=[100,40,-100,80,.5],Upper=[120,100,0,max(xdata),1],Lower=[80,10,-300,min(xdata),0]);
disp(f1)
General model:
f1(x) = a0+a1*xmapped(x,x1,xint1)+a2*xmapped(x,x1,xint1).^2
Coefficients (with 95% confidence bounds):
a0 = 100.4 (100.1, 100.7)
a1 = 84.02 (81.7, 86.35)
a2 = -186.8 (-189, -184.7)
x1 = 79.46 (79.23, 79.69)
xint1 = 0.4583 (0.4504, 0.4663)
plot(f1,xdata,ydata); grid on
That is better than I expected. You could extend this idea to a 2D data set:
z=h(x,y)=f(xint(x))+g(yint(y))
which uses a mapping from x to xint and a mapping from y to yint. Each of those mappings introduces two adjustable parameters, if you have one breakpoint in each. Or you could remap just one of the independent variables.