matlab怎么做多元非线性拟合,如何用matlab进行多元非线性拟合

名流

幼苗

共回答了17个问题采纳率:100%

function zd487022570

x1=[0.25,0.278,0.3125,0.357,0.4167,0.3,0.3333,0.375,0.7286,0.5];

x2=[0,0.1111,0.125,0.14286,0.1667,0,0.1111,0.125,0.14286,0.1667];

x3=[0,0,0.125,0.2857,0.5,0,0,0.125,0.2857,0.5];

y=[0.7572,0.6559,0.6383,0.5636,0.4884,0.9783,0.7489,0.686,0.6288,0.4934];

x = [x1; x2; x3];

% 使用最小二乘拟合:

% opt指定拟合选项(注意查看命令窗口提示的优化终止条件,如对结果不满意考虑适当修改)

% b0为初值(要慎重选择,不同初值得到的结果可能不同)

opt = optimset('MaxFunEvals',50000,'MaxIter',10000,'TolFun',1E-10)

% b0 = [0 -10 1 1];

% b0 = [0.6 -60 15 0.7];

b0 = [0.7 -137 40 0.7];

b = lsqcurvefit(@myfun,b0,x,y,[],[],opt);

A = b(1)

B = b(2)

C = b(3)

D = b(4)

% 把拟合结果与原始数据对照

plot(y,'-o');

hold on

你可能感兴趣的:(matlab怎么做多元非线性拟合,如何用matlab进行多元非线性拟合)