lsqcurvefit在matlab中拟合多元函数问题这是M文件:function F=myfun(x,data)F=x(1)+x(2)*xdata(:,1)+x(3)*xdata(:,1).^2+x(4)*xdata(:,2)+x(5)*data(:,2).^2;下面是数据:xdata=[14.9,0.8;13.6,0.62;13.6,0.98;16.2,0.98;16.2,0.62];ydata=[11172
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/23 13:37:39
lsqcurvefit在matlab中拟合多元函数问题这是M文件:function F=myfun(x,data)F=x(1)+x(2)*xdata(:,1)+x(3)*xdata(:,1).^2+x(4)*xdata(:,2)+x(5)*data(:,2).^2;下面是数据:xdata=[14.9,0.8;13.6,0.62;13.6,0.98;16.2,0.98;16.2,0.62];ydata=[11172
lsqcurvefit在matlab中拟合多元函数问题
这是M文件:
function F=myfun(x,data)
F=x(1)+x(2)*xdata(:,1)+x(3)*xdata(:,1).^2+x(4)*xdata(:,2)+x(5)*data(:,2).^2;
下面是数据:
xdata=[14.9,0.8;13.6,0.62;13.6,0.98;16.2,0.98;16.2,0.62];
ydata=[111729.4346 111742.47 111742.4947 111738.3368 111738.2256];
x0=[10,1]
[x,resnorm]=lsqcurvefit(@myfun,x0,xdata,ydata)
提示错误:function F=myfun(x,data)
|
Error:Function definitions are not permitted in this context.
Error using ==> feval
Undefined function or method 'myfun' for input arguments of type 'double'.
Error in ==> lsqcurvefit at 209
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation.LSQCURVEFIT cannot continue.
lsqcurvefit在matlab中拟合多元函数问题这是M文件:function F=myfun(x,data)F=x(1)+x(2)*xdata(:,1)+x(3)*xdata(:,1).^2+x(4)*xdata(:,2)+x(5)*data(:,2).^2;下面是数据:xdata=[14.9,0.8;13.6,0.62;13.6,0.98;16.2,0.98;16.2,0.62];ydata=[11172
function有问题 应该为xdata 而不是data
function F=myfun(x,xdata)
F=x(1)+x(2)*xdata(:,1)+x(3)*xdata(:,1).^2+x(4)*xdata(:,2)+x(5)*xdata(:,2).^2;