expfitxy.m

来自「fit programme for a serials of data」· M 代码 · 共 16 行

M
16
字号
function estimates=expfitxy(x,y)
%input x is 1-by-N vector
%      y is 1-by-N vector
%output a is the coeficient of fitting formula y=a*exp(bx)
model=@expxy;
[estimates]=fminsearch(model,rand(1,2));
%define the function of condition for fitting formula
function f=expxy(params)
n=length(x);
f=0;
f1=@(x1) params(1)*exp(params(2)*x1);
for i=1:n
    f=f+(f1(x(i))-y(i))^2;
end
end
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?