📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Edit16: TEdit;
Edit17: TEdit;
Edit18: TEdit;
Edit19: TEdit;
Edit20: TEdit;
Button1: TButton;
Edit12: TEdit;
StringGrid1: TStringGrid;
Edit21: TEdit;
Edit22: TEdit;
Chart1: TChart;
Series1: TLineSeries;
Series2: TLineSeries;
Button3: TButton;
Button4: TButton;
Edit23: TEdit;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
StringGrid2: TStringGrid;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var q:integer;
p1,p2,p3,p4,p5:array[1..11]of double;
ra,rb,f:double;
//计算m到n的ra,rb值,并判断有没有符合条件的k值
function nh(var m,n:integer):integer;
var a,b2,b3,b4,b5:double;
y,j:integer;
begin
f:=strtofloat(form1.Edit23.Text);
b2:=0;
b3:=0;
b4:=0;
b5:=0;
ra:=0;
rb:=0;
for j:=m to n do
begin
b5:=b5+p5[j];
b2:=b2+p2[j];
b3:=b3+p3[j];
b4:=b4+p4[j];
end;
ra:=round(((n-m+1)*b5-b2*b3)/((n-m+1)*b4-b2*b2)*100000000000)/100000000000;
rb:=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(p3[j]-(p2[j]*ra+rb))/p3[j])-(f/100) ;
if a<0 then
begin
y:=y+1 ;
end ;
end;
nh:=y;
end;
//提取字符串中的一段两位字符
//确定m到n之间的有效k值 ,并计算出此时的 M‘
function qm(var z,x:integer):integer;
var d,b,s:integer;
lt,p:integer;
a, g,t:double;
begin
d:=z;
s:=x;
while d<s do
begin
lt:=nh(d,s);
p:=(lt-s+d-1);
if p<>0 then
begin
s:=s-1 ;
end
else
//写ra,rb值
begin
qm:=s;
q:=q+1;
form1.StringGrid1.Cells[3,q]:=floattostr(ra);
form1.StringGrid1.Cells[4,q]:=floattostr(rb);
form1.StringGrid1.Cells[6,q]:=inttostr(s);
if q>=2 then
begin
//计算并写rq值
g:=abs(strtofloat(form1.StringGrid1.Cells[4,q-1])-strtofloat(form1.StringGrid1.Cells[4,q]));
t:=abs(strtofloat(form1.StringGrid1.Cells[3,q-1])-strtofloat(form1.StringGrid1.Cells[3,q]));
a:=g/t;
form1.StringGrid1.Cells[2,q]:=floattostr(a);
for b:=d to s do
form1.StringGrid1.Cells[5,b]:=floattostr( p2[b]*ra+rb);
exit;
end
else if q<=1 then
begin
for b:=d to s do
form1.StringGrid1.Cells[5,b]:=floattostr( p2[b]*ra+rb);
exit;
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var bu:integer;
begin
for bu:=1 to 11 do
begin
form1.StringGrid1.Cells[1,bu]:='' ;
end;
//标注单元格
form1.StringGrid1.Cells[1,0]:='误差值';
form1.StringGrid1.Cells[2,0]:='R值';
form1.StringGrid1.Cells[3,0]:='A值';
form1.StringGrid1.Cells[4,0]:='B值';
form1.StringGrid1.Cells[5,0]:='k修正值';
//求误差
form1.StringGrid1.Cells[1,1]:=floattostr(round(strtofloat(form1.Edit1.Text)/strtofloat(form1.Edit12.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,2]:=floattostr(round(strtofloat(form1.Edit2.Text)/strtofloat(form1.Edit13.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,3]:=floattostr(round(strtofloat(form1.Edit3.Text)/strtofloat(form1.Edit14.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,4]:=floattostr(round(strtofloat(form1.Edit4.Text)/strtofloat(form1.Edit15.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,5]:=floattostr(round(strtofloat(form1.Edit5.Text)/strtofloat(form1.Edit16.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,6]:=floattostr(round(strtofloat(form1.Edit6.Text)/strtofloat(form1.Edit17.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,7]:=floattostr(round(strtofloat(form1.Edit7.Text)/strtofloat(form1.Edit18.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,8]:=floattostr(round(strtofloat(form1.Edit8.Text)/strtofloat(form1.Edit19.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,9]:=floattostr(round(strtofloat(form1.Edit9.Text)/strtofloat(form1.Edit20.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,10]:=floattostr(round(strtofloat(form1.Edit10.Text)/strtofloat(form1.Edit21.Text)*1000000000000000)/1000000000000000);
form1.StringGrid1.Cells[1,11]:=floattostr(round(strtofloat(form1.Edit11.Text)/strtofloat(form1.Edit22.Text)*1000000000000000)/1000000000000000);
// rreal
p1[1]:= strtofloat(form1.edit1.text);
p1[2]:= strtofloat(form1.edit2.text);
p1[3]:= strtofloat(form1.edit3.text);
p1[4]:= strtofloat(form1.edit4.text);
p1[5]:= strtofloat(form1.edit5.text);
p1[6]:= strtofloat(form1.edit6.text);
p1[7]:= strtofloat(form1.edit7.text);
p1[8]:= strtofloat(form1.edit8.text);
p1[9]:= strtofloat(form1.edit9.text);
p1[10]:= strtofloat(form1.edit10.text);
p1[11]:= strtofloat(form1.edit11.text);
//rusm
p2[1]:= strtofloat(form1.edit12.text);
p2[2]:= strtofloat(form1.edit13.text);
p2[3]:= strtofloat(form1.edit14.text);
p2[4]:= strtofloat(form1.edit15.text);
p2[5]:= strtofloat(form1.edit16.text);
p2[6]:= strtofloat(form1.edit17.text);
p2[7]:= strtofloat(form1.edit18.text);
p2[8]:= strtofloat(form1.edit19.text);
p2[9]:= strtofloat(form1.edit20.text);
p2[10]:= strtofloat(form1.edit21.text);
p2[11]:= strtofloat(form1.edit22.text);
//k值
p3[1]:= round(strtofloat(form1.Edit1.Text)/strtofloat(form1.Edit12.Text)*1000000000000000)/1000000000000000;
p3[2]:= round(strtofloat(form1.Edit2.Text)/strtofloat(form1.Edit13.Text)*1000000000000000)/1000000000000000;
p3[3]:= round(strtofloat(form1.Edit3.Text)/strtofloat(form1.Edit14.Text)*1000000000000000)/1000000000000000;
p3[4]:= round(strtofloat(form1.Edit4.Text)/strtofloat(form1.Edit15.Text)*1000000000000000)/1000000000000000;
p3[5]:= round(strtofloat(form1.Edit5.Text)/strtofloat(form1.Edit16.Text)*1000000000000000)/1000000000000000;
p3[6]:= round(strtofloat(form1.Edit6.Text)/strtofloat(form1.Edit17.Text)*1000000000000000)/1000000000000000;
p3[7]:= round(strtofloat(form1.Edit7.Text)/strtofloat(form1.Edit18.Text)*1000000000000000)/1000000000000000;
p3[8]:= round(strtofloat(form1.Edit8.Text)/strtofloat(form1.Edit19.Text)*1000000000000000)/1000000000000000;
p3[9]:= round(strtofloat(form1.Edit9.Text)/strtofloat(form1.Edit20.Text)*1000000000000000)/1000000000000000;
p3[10]:=round(strtofloat(form1.Edit10.Text)/strtofloat(form1.Edit21.Text)*1000000000000000)/1000000000000000;
p3[11]:=round(strtofloat(form1.Edit11.Text)/strtofloat(form1.Edit22.Text)*1000000000000000)/1000000000000000;
//rusm*rusm
p4[1]:=p2[1]*p2[1];
p4[2]:=p2[2]*p2[2];
p4[3]:=p2[3]*p2[3];
p4[4]:=p2[4]*p2[4];
p4[5]:=p2[5]*p2[5];
p4[6]:=p2[6]*p2[6];
p4[7]:=p2[7]*p2[7];
p4[8]:=p2[8]*p2[8];
p4[9]:=p2[9]*p2[9];
p4[10]:=p2[10]*p2[10];
p4[11]:=p2[11]*p2[11];
//rusm*k
p5[1]:=p2[1]*p3[1];
p5[2]:=p2[2]*p3[2];
p5[3]:=p2[3]*p3[3];
p5[4]:=p2[4]*p3[4];
p5[5]:=p2[5]*p3[5];
p5[6]:=p2[6]*p3[6];
p5[7]:=p2[7]*p3[7];
p5[8]:=p2[8]*p3[8];
p5[9]:=p2[9]*p3[9];
p5[10]:=p2[10]*p3[10];
p5[11]:=p2[11]*p3[11];
end;
//从1到11循环求取k值;
procedure TForm1.Button3Click(Sender: TObject);
var l,o,b,js,mb:integer;
begin
for js:=1 to 11 do
begin
form1.StringGrid1.Cells[5,js]:='' ;
form1.StringGrid1.Cells[0,js]:='' ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -