如何用matlab拟合函数?
发布网友
发布时间:2022-05-03 00:40
我来回答
共1个回答
热心网友
时间:2022-07-01 05:19
在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function g=_31(a,p)
%其中G,D,n分别用a(1),a(2),a(3)代替
G=a(1);
D=a(2);
n=a(3);
g=G*exp(-(D*log(4700./p))^n);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在Matlab下输入
p=[
759.9
1834.5
3064.7
4358.6
5695.4
7031.3
8348.0
9475.3];
g=[
6.108909907
12.86663816
18.1161568
23.69979432
28.37868993
32.08847637
34.242214
36.58519694];
[A,res]=lsqcurvefit('_31',ones(1,4),p,g);
A
%注意我这里没有MATLAB,你可以上网看一下lsqcurvefit的例子