matlab中lsqcurvefit函数报错问题函数程序:function f=myfun(a,x)f=a(1)*35*exp(a(2)*x+a(3)*x^2);命令:x=[11.6 12.8 14.1 14.4 13.9 13 12.4];y=[-0.3 -1 -1.48 -1.16 -1.26 -0.67 -0.73];a0=[0,0];[x,Resnorm]=lsqcurvefit(@myfun,a0,x,y)报错:E
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/29 12:56:51
![matlab中lsqcurvefit函数报错问题函数程序:function f=myfun(a,x)f=a(1)*35*exp(a(2)*x+a(3)*x^2);命令:x=[11.6 12.8 14.1 14.4 13.9 13 12.4];y=[-0.3 -1 -1.48 -1.16 -1.26 -0.67 -0.73];a0=[0,0];[x,Resnorm]=lsqcurvefit(@myfun,a0,x,y)报错:E](/uploads/image/z/3942077-5-7.jpg?t=matlab%E4%B8%ADlsqcurvefit%E5%87%BD%E6%95%B0%E6%8A%A5%E9%94%99%E9%97%AE%E9%A2%98%E5%87%BD%E6%95%B0%E7%A8%8B%E5%BA%8F%EF%BC%9Afunction+f%3Dmyfun%28a%2Cx%29f%3Da%281%29%2A35%2Aexp%28a%282%29%2Ax%2Ba%283%29%2Ax%5E2%29%3B%E5%91%BD%E4%BB%A4%EF%BC%9Ax%3D%5B11.6+12.8+14.1+14.4+13.9+13+12.4%5D%3By%3D%5B-0.3+-1+-1.48+-1.16+-1.26+-0.67+-0.73%5D%3Ba0%3D%5B0%2C0%5D%3B%5Bx%2CResnorm%5D%3Dlsqcurvefit%28%40myfun%2Ca0%2Cx%2Cy%29%E6%8A%A5%E9%94%99%EF%BC%9AE)
matlab中lsqcurvefit函数报错问题函数程序:function f=myfun(a,x)f=a(1)*35*exp(a(2)*x+a(3)*x^2);命令:x=[11.6 12.8 14.1 14.4 13.9 13 12.4];y=[-0.3 -1 -1.48 -1.16 -1.26 -0.67 -0.73];a0=[0,0];[x,Resnorm]=lsqcurvefit(@myfun,a0,x,y)报错:E
matlab中lsqcurvefit函数报错问题
函数程序:
function f=myfun(a,x)
f=a(1)*35*exp(a(2)*x+a(3)*x^2);
命令:
x=[11.6 12.8 14.1 14.4 13.9 13 12.4];
y=[-0.3 -1 -1.48 -1.16 -1.26 -0.67 -0.73];
a0=[0,0];
[x,Resnorm]=lsqcurvefit(@myfun,a0,x,y)
报错:
Error using ==> optim\private\lsqncommon at 98
LSQCURVEFIT cannot continue because user supplied objective function failed with the following error:
Attempted to access a(3); index out of bounds because numel(a)=2.
Error in ==> lsqcurvefit at 182
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
matlab中lsqcurvefit函数报错问题函数程序:function f=myfun(a,x)f=a(1)*35*exp(a(2)*x+a(3)*x^2);命令:x=[11.6 12.8 14.1 14.4 13.9 13 12.4];y=[-0.3 -1 -1.48 -1.16 -1.26 -0.67 -0.73];a0=[0,0];[x,Resnorm]=lsqcurvefit(@myfun,a0,x,y)报错:E
你自己定义的函数用到了a[3],但是你给的那个a0只有两项,他不知道该怎么办了.