logo资料库

lsqcurvefit函数实例.doc

第1页 / 共1页
资料共1页,全文预览结束
lsqcurvefit 函数使用实例 例:方程: ( ) ydata i  x (1)  e ( (2) x  xdata i ( )) 最小化以下函数: 1min 2 x m  i 1  ( F x xdata ( , ) i  ydata ) i 2 初始值为: 0 x  [100; 1]  首先编 M 文件,文件名为:fun_lsqcurvefit.m function f=fun_lsqcurvefit(x,xdata) f=x(1)*exp(x(2)*xdata); 再运行: clc;clear all; xdata=[0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; ydata=[455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5]; x0=[100;-1]; [x,resnorm]=lsqcurvefit(@fun_lsqcurvefit,x0,xdata,ydata) 运行结果: x = 498.8309 -0.1013 resnorm = 9.5049
分享到:
收藏