Least square curve fitting to 2 -input 1-ouput 2D matrices
Mostrar comentarios más antiguos
Hi,
I have two input variables (x1,x2) one output variable (Y) for a model. The function is as follows, Y = a*exp(b*x1) + c*exp(d*x2)
The input-output variables and are all matrices of 400x400 size. I need to determine the coefficients a,b,c,d that best describe the relationship between (x1,x2) and Y. With single input single output, the lsqcurvefit method is straightforward, but I am not finding the right way to deal with 2-inputs.
Here is what I have done so far. Let x1 and x2 be 400x400 matrices which produce a 400x400 Y matrix.
Z = [x1 x2];
fun = @(x,Z)(x(1)*exp(x(2)*Z(:,1:400))+ x(3)*exp(x(4)*Z(:,401:800)));
x0 = [1,1,1,1];
lb = [0 0 0 0];
ub = [10 10 10 10];
x_ans = lsqcurvefit(fun,x0,Z,Y,lb,ub)
I am not sure if I am setting Z correctly and also if this method will work properly as the coefficients are not providing the best fit.
Please advise.
Regards, Salman
Respuestas (0)
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!