MATLAB自带了一些基于幂函数的拟合方式,这个blog记录的是按照任意指定函数形式进行拟合;
代码附上,自己摸索。本次拟合是拟合一个给定的函数形式,其中带有位置参数a和b。
clc;
clear;
% the first one;
R=[0.68 0.805 0.863 0.893 0.9122 0.916];
x=[1.07 2.24 3.86 5.91 8.5 11.5];
y=R./(1-R);
plot(x,y,'ro')
hold on
x=x'; % transfer Row matrix to Column matrix;
y=y';
p=fittype('(x/a)*exp(-x/b)') % Fitting function
f=fit(x,y,p)
plot(f,x,y);