I have a system of 3 equations with 3 independent variables( x1,x2,x3) and correspondingly 1 dependent variables y as follows: y=k1(1-exp(k2*x1))*x3^2+k3*x3*(x1*x2)^2+k4*x3*(x1*x2)+k5*x3*(x1*x2)^0.5+k6*x3+k7-K7exp(k8*x1) x and y data are available.
I need to fit 8 parameters( k1,k2,k3,k4,k5,k6,k7,k8) in this system.
My code as follow: xdata = horzcat(x1,x2,x3,x4,x5); ydata = horzcat(y1,y2,y3); fun=@(b,xdata)horzcat(b(1)*x5-b(1)*exp(b(2)*x1)*x3.*x3+b(3)*x3.*(x1.*x2)+b(4)*x3.*x2+b(5)*x3.*x2^0.5+b(6)*x3+b(7)-b(7)*exp(b(8)*x1),0,0); b0=[0;0;0;0;0;0;0;0]; b = lsqcurvefit(fun,b0,xdata,ydata)
the operation result is :Matrix dimensions must be consistent.
mistake: @(b,xdata)horzcat(b(1)*x5-b(1)*exp(b(2)*x1)*x3.*x3+b(3)*x3.*(x1.*x2)+b(4)*x3.*x2+b(5)*x3.*x2^0.5+b(6)*x3+b(7)-b(7)*exp(b(8)*x1),0,0)
Failure:lsqcurvefit (line 198) initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot continue.
I tried using lsqcurvefit but couldn't make it work for this case. Suggest me how to solve this problem. Thank you.
Best Answer