如何用matlab拟合函数?p=759.91,834.53,064.74,358.65,695.47,031.38,348.09,475.3对应的g=6.10890990712.8666381618.116156823.6997943228.3786899332.0884763734.24221436.58519694函数:ln(g/G)=-(Dln(p/P))^n其中G,D,n是需要拟合的常数,P=4700
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 12:41:41
如何用matlab拟合函数?p=759.91,834.53,064.74,358.65,695.47,031.38,348.09,475.3对应的g=6.10890990712.8666381618.116156823.6997943228.3786899332.0884763734.24221436.58519694函数:ln(g/G)=-(Dln(p/P))^n其中G,D,n是需要拟合的常数,P=4700
如何用matlab拟合函数?
p=
759.9
1,834.5
3,064.7
4,358.6
5,695.4
7,031.3
8,348.0
9,475.3
对应的g=
6.108909907
12.86663816
18.1161568
23.69979432
28.37868993
32.08847637
34.242214
36.58519694
函数:ln(g/G)=-(Dln(p/P))^n
其中G,D,n是需要拟合的常数,P=4700
函数可转变形式为:g=G*exp[-(D*ln(4700/p))^n],实验结果是数组p,g,需要拟合的常数是G,D,n ,各位大虾请多多指教.
如何用matlab拟合函数?p=759.91,834.53,064.74,358.65,695.47,031.38,348.09,475.3对应的g=6.10890990712.8666381618.116156823.6997943228.3786899332.0884763734.24221436.58519694函数:ln(g/G)=-(Dln(p/P))^n其中G,D,n是需要拟合的常数,P=4700
在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function g=zhidao_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('zhidao_31',ones(1,4),p,g);
A
%注意我这里没有MATLAB,你可以上网看一下lsqcurvefit的例子