非线性回归
Non linear regression
我正在尝试进行非线性回归以找到具有最小二乘曲线的常数 Is 和 n fitting.This 是公式 Is(exp(1).^(V/26.*n))
这是我的代码
fun = @(n,Is)Is(exp(1).^(V/26.*n));
x0 = [0,14];
x = lsqcurvefit(fun,x0,V,I)
它重新运行以下内容
Matrix dimensions must agree.
Error in @(n,Is)Is(exp(1).^(V/26.*n))
Error in lsqcurvefit (line 202)
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Caused by:
Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
来自https://www.mathworks.com/help/optim/ug/lsqcurvefit.html
Function you want to fit, specified as a function handle or the name of a function. fun is a function that takes two inputs: a vector or matrix x, and a vector or matrix xdata. fun returns a vector or matrix F, the objective function evaluated at x and xdata.
在您的情况下,您的 fun
仅获取适合的参数,而不是数据。我建议将其更改为
fun = @(X,V) X(2)*(exp(1).^(V/26.*X(1)));
我正在尝试进行非线性回归以找到具有最小二乘曲线的常数 Is 和 n fitting.This 是公式 Is(exp(1).^(V/26.*n))
这是我的代码
fun = @(n,Is)Is(exp(1).^(V/26.*n));
x0 = [0,14];
x = lsqcurvefit(fun,x0,V,I)
它重新运行以下内容
Matrix dimensions must agree.
Error in @(n,Is)Is(exp(1).^(V/26.*n))
Error in lsqcurvefit (line 202) initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Caused by: Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
来自https://www.mathworks.com/help/optim/ug/lsqcurvefit.html
Function you want to fit, specified as a function handle or the name of a function. fun is a function that takes two inputs: a vector or matrix x, and a vector or matrix xdata. fun returns a vector or matrix F, the objective function evaluated at x and xdata.
在您的情况下,您的 fun
仅获取适合的参数,而不是数据。我建议将其更改为
fun = @(X,V) X(2)*(exp(1).^(V/26.*X(1)));