I have tried matlab's curve fitting which works well, but in case of surface fitting matlab is disregarding the second independent variable. Below is an example that replicates the problem.
function curve_fitting_test()
x1 = (1:100)';
x2 = (1:100)';
y = 10.*x1 + 20.*x2 + 30;
ft = fittype(@(a,b,c,x1,x2)a.*x1 + b.*x2 + c, 'independent', {'x1', 'x2'});
cf = fit([x1 x2], y, ft, 'start', [25 25 25], 'Lower', [0 0 0], 'Upper', [50 50 50])
This is the model which matlab is generating:
General model: cf(x1,x2) = a.*x1+b.*x2+c Coefficients (with 95% confidence bounds): a = 15 (15, 15) b = 15 (15, 15) c = 30 (30, 30)