文档库 最新最全的文档下载
当前位置:文档库 › 曲线拟合程序

曲线拟合程序

function Tkcheckone.nh(var m,n:integer):integer;
var a,b2,b3,b4,b5:double;
y,j:integer;
begin
f1:=0.001;
b2:=0;
b3:=0;
b4:=0;
b5:=0;
ra1:=0;
rb1:=0;
for j:=m to n do
begin
b5:=b5+p15[j];
b2:=b2+p12[j];
b3:=b3+p13[j];
b4:=b4+p14[j];
end;
ra1:=round(((n-m+1)*b5-b2*b3)/((n-m+1)*b4-b2*b2)*100000000000)/100000000000;
rb1:=round( ((b3*b4-b2*b5)/((n-m+1)*b4-b2*b2))*100000000000)/100000000000; //(b3-ra*b2)/(n-m+1)
y:=0;
for j:=m to n do
begin
a:=(abs(p13[j]-(p12[j]*ra1+rb1))/p13[j])-(f1/100) ;
if a<0 then
begin
y:=y+1 ;
end ;
end;
nh:=y;
end;
function Tkcheckone.qm(var z,x:integer):integer;
var d,b,s:integer;
lt,p:integer;
a,g,t:double;
begin
d:=z;
s:=x;
while dbegin
lt:=nh(d,s);
p:=(lt-s+d-1);
if p<>0 then
begin
s:=s-1 ;
end
else //写ra,rb值
begin
qm:=s;
q1:=q1+1;
form5.StringGrid1.Cells[3,q1]:=floattostr(ra1);
form5.StringGrid1.Cells[4,q1]:=floattostr(rb1);
form5.StringGrid1.Cells[6,q1]:=inttostr(s);
if q1>=2 then
begin //计算并写rq值
g:=abs(strtofloat(form5.StringGrid1.Cells[4,q1-1])-strtofloat(form5.StringGrid1.Cells[4,q1]));
t:=abs(strtofloat(form5.StringGrid1.Cells[3,q1-1])-strtofloat(form5.StringGrid1.Cells[3,q1]));
a:=g/t;
form5.StringGrid1.Cells[2,q1]:=floattostr(a);
for b:=d to s do
begin
form5.StringGrid1.Cells[5,b]:=floattostr( p12[b]*ra1+rb1);
end;
exit;
end
else if q1<=1 then
begin
for b:=d to s do
begin
form5.StringGrid1.Cells[5,b]:=floattostr( p12[b]*ra1+rb1);
end;
exit;
end;
end;
end;
end;



procedure Tkcheckone.Execute;
var int1,int2:integer;
i,j,k:integer;
l,o,b,js,mb:integer;
begin
form5.StringGrid1.Cells[1,0]:='误差值';
form5.StringGrid1.Cells[2,0]:='R值';
form5.StringGrid1.Cells[3,0]:='A值';
form5.StringGrid1.Cells[4,0]:='B值';
form5.StringGrid1.Cells[5,0]:='k修正值';
int1:=form2.StringGrid1.rowCount-strtoint(form5.Edit15.text); //数据条数
showmessage('111');
int2:=form2.StringGrid1.rowCount;
form5.StringGrid1.RowCount:=int1;
for i:=1 to int1 do
begin
for j:=0 to 7 do
begin
form5.StringGrid1.cells[j,i]:='';
end;
end;
for i:=1 to int1 do
begin
p11[i]:=strtofloat(form2.StringGrid1.Cells[1,int2-i]); //标准
p12[i]:=strtofloat(form2.StringGrid1.cells[2,int2-i]); //实测
p13[i]:=round(p11[i]/p12[i]*1000000000000000)/1000000000000000;
p14[i]:=p12[i]*p12[i];
p15[i]:=p12[i]*p13[i];
form5.StringGr

id1.Cells[0,i]:=floattostr(p13[i]);
end;
q1:=0;
l:=1;
b:=int1;
while lbegin
o:=qm(l,b);
l:=o;
end;
form5.StringGrid1.Cells[2,1]:='15000';
end;

相关文档
相关文档 最新文档