如何用matlab进行多元非线性拟合自定义函数 y=A*x1/(1+B*x2+C*x3)+D 其中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
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/22 21:29:14
如何用matlab进行多元非线性拟合自定义函数 y=A*x1/(1+B*x2+C*x3)+D 其中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
如何用matlab进行多元非线性拟合
自定义函数
y=A*x1/(1+B*x2+C*x3)+D
其中
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];
求可执行代码!求出回归系数A、B、C、D!
如何用matlab进行多元非线性拟合自定义函数 y=A*x1/(1+B*x2+C*x3)+D 其中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
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
plot(myfun(b,x),'r:x');
function y = myfun(x,xdata)
A = x(1);
B = x(2);
C = x(3);
D = x(4);
x1 = xdata(1,:);
x2 = xdata(2,:);
x3 = xdata(3,:);
y = A*x1./(1+B*x2+C*x3)+D;