⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitlinearregress2.pas

📁 一个多元非线性回归分析源码以及其中的公式列表
💻 PAS
字号:
unit UnitLinearRegress;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, ValEdit, ExtCtrls, StdCtrls, Menus, math, Clipbrd, jpeg,
  Animate, GIFCtrl, Compile_Hss, CPUCounter_Hss, Buttons, TextZhi_Hss;

type
  TfrmMain = class(TForm)
    procedure FormCanResize(Sender: TObject; var NewWidth,
      NewHeight: Integer; var Resize: Boolean);
    procedure VLE_DataKeyPress(Sender: TObject; var Key: Char);
    procedure N11Click(Sender: TObject);
    procedure VLE_DataStringsChange(Sender: TObject);
    procedure VLE_ValueKeyPress(Sender: TObject; var Key: Char);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;
  
var dd1   :Extended;

implementation

uses UnitLinearRegressFunction, UnitAbout, UnitHelp;//, UnitAuto;

{$R *.dfm}

procedure TfrmMain.FormCanResize(Sender: TObject; var NewWidth,
  NewHeight: Integer; var Resize: Boolean);
begin
   //if (NewWidth<640) then NewWidth:=640;
   //if (NewHeight<480) then NewHeight:=480;
end;

procedure TfrmMain.VLE_DataKeyPress(Sender: TObject; var Key: Char);
begin
    Key:=upcase(Key);
    //showmessage(inttostr(byte(key)));
    case Key of
        '0','1','2','3','4','5','6','7','8','9': Key:=Key;
        'E','.','-','+': Key:=Key;
        #8,#9,#13: Key:=Key;
        else Key:=#0;
    end;
end;

procedure TfrmMain.N11Click(Sender: TObject);
begin
    if  N11.Checked then
        self.FormStyle:=fsNormal
    else
        self.FormStyle:=fsStayOnTop;
    self.N11.Checked:= not(self.N11.Checked);
end;

procedure TfrmMain.VLE_DataStringsChange(Sender: TObject);
begin
    self.RadioButton1.Checked :=false;
    self.RadioButton2.Checked :=false;
    //SetVLEData(VLE_Value);
    VLE_Value.Strings.Text:='';
    self.ImgLine.Visible:=false;
end;

procedure TfrmMain.VLE_ValueKeyPress(Sender: TObject;
  var Key: Char);
begin
    Key:=#0;
end;

procedure TfrmMain.Button1Click(Sender: TObject);
var x,y     :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            y:= strtofloat(self.Edit1.Text);
            x:=x+y;
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            y:= strtofloat(self.Edit1.Text);
            x:=x+y;
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('加法计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button2Click(Sender: TObject);
var x,y     :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin         
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            y:=strtofloat(self.Edit2.Text);
            x:=x*y;
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            y:=strtofloat(self.Edit2.Text);
            x:=x*y;
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('乘法计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button3Click(Sender: TObject);
var x,y     :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin        
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            y:=strtofloat(self.Edit3.Text);
            if y-trunc(y)=0 then
            begin
                x:=IntPower(x,trunc(y));
            end
            else
                x:=exp(ln(x)*y);
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            y:=strtofloat(self.Edit3.Text);
            if y-trunc(y)=0 then
            begin
                x:=IntPower(x,trunc(y));
            end
            else
                x:=exp(ln(x)*y);
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('次方计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button10Click(Sender: TObject);
var x,y     :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            y:=strtofloat(self.Edit4.Text);
            x:=ln(x)/ln(y);
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            y:=strtofloat(self.Edit4.Text);
            x:=ln(x)/ln(y);
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('求对数计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button4Click(Sender: TObject);
var x       :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            x:=sin(x);
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            x:=sin(x);
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('Sin计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button6Click(Sender: TObject);
var x       :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            x:=cos(x);
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            x:=cos(x);
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('Cos计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button8Click(Sender: TObject);
var x       :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            x:=tan(x);
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            x:=tan(x);
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('Sin计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button5Click(Sender: TObject);
var x       :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            x:=arcsin(x);
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            x:=arcsin(x);
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('ArcSin计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button7Click(Sender: TObject);
var x       :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            x:=arccos(x);
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            x:=arccos(x);
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('ArcCos计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

procedure TfrmMain.Button9Click(Sender: TObject);
var x       :double;
    i       :integer;
    n       :integer;
    DataOld :string;
begin
    n:=1;
    DataOld:=VLE_Data.Strings.Text;
  try
    if self.RadioButton1.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            n:=i;
            x:=strtofloat(self.VLE_Data.Cells[0,i]);
            x:=Arctan(x);
            self.VLE_Data.Cells[0,i]:=floattostr(x);
        end;
    end
    else if self.RadioButton2.Checked  then
    begin
        for i:=1 to self.VLE_Data.RowCount-1 do
        begin
            x:=strtofloat(self.VLE_Data.Cells[1,i]);
            x:=Arctan(x);
            self.VLE_Data.Cells[1,i]:=floattostr(x);
        end;
    end
    else
    begin
        application.MessageBox('请先选定是针对x轴还是y轴进行计算。','提醒:',MB_ICONINFORMATION);
    end;
  except
    application.MessageBox(Pchar('Arctg计算在计算第'+inttostr(n)+'行数据时出现错误。'),'出错:',MB_ICONERROR);
    VLE_Data.Strings.Text:=DataOld;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -