3.0的似乎没有可以下载的。。我的是1.5版本的
这个例子里,有三个变量,我之前用matlab尝试过用lsqnonlin函数拟合,matlab也不太会呢,似乎运行不对的
function F=Torfac(d,Data)
d=1:6;
L=44; %cm
Data=[0.95286646053 7.31174393 45.90818274
1.0675890636 7.74423607 44.88095647
1.2070326551 8.708188311 56.666422786
1.2891664894 9.45328306 69.870900159
1.371300061 10.309441311 72.423575922
1.5246342784 11.00918745 77.923426956
1.7982441944 12.63134323 87.625605046
2.0530550486 14.22717859 96.124313224
2.4533315015 17.82962177 115.26023012
2.6266643202 18.226344191 119.23084942
2.856667018 19.9127711 132.53090467
3.0838023283 21.3538607 136.76386882
3.6142052724 24.92344013 161.35438276
3.987415716 27.120747051 176.52416388
4.8679566752 33.00078812 220.1193594
5.9622115035 40.50833169 283.81985361
6.9308234511 45.90868196 335.91465167];
xdata=Data(:,1);ydata=Data(:,2);zdata=Data(:,3);
d0=[1,1,1,1,1,1];
for i=1:length(xdata)
M(i)=((-ydata(i)+(L*d(1)+d(2))*xdata(i)+d(3))^2)+((-zdata(i)+(2*L*d(3)+d(4))*xdata(i)+d(5)*xdata(i)^2+d(6)*d(1)^2*xdata(i)^3+2*d(2)^2)^2);
i=i+1;
end
F=sum(M);
options=optimset('LargeScale','off');
options=optimset(options,'MaxFunEvals',300);
options=optimset(options,'LevenbergMarquardt','off');
options=optimset(options,'LineSearch','cubicpoly');
d=lsqnonlin('Torfac',d0,[],[],options,Data);
[ 本帖最后由 sophio 于 2009-5-17 11:01 编辑 ] |