contoh script CURVE FITTING ordo n

 Berikut ini Script Dari CURVE FITTING ordo  n


procedure TForm3.Button1Click(Sender: TObject);
var a,b :integer;
begin

 a:= strtoint(edit1.text);
 b:= strtoint(edit2.text);

  stringgrid1.colcount := a ;
  stringgrid1.rowcount := b ;
end;

procedure TForm3.Button2Click(Sender: TObject);
begin
   for i := 1 to stringgrid1.RowCount - 1 do
    begin
          stringgrid1.Cells [0,i] := inputbox('Input','Isi Data','') ;
        end;
end;

procedure TForm3.Button3Click(Sender: TObject);
var a0,a1,a2,a3,a4,a5,a6,a7,a8,x,x0,x1,x2,x3,x4,x5,x6,x7,x8,
l0,l1,l2,l3,l4,l5,l7,l6,l8,p : real ;
begin
x  := strtofloat(edit3.Text) ;
p := 0;
                           a0 := strtofloat ( stringgrid1.Cells[1,1]);
                           a1 := strtofloat ( stringgrid1.Cells[1,2]);
                           a2 := strtofloat ( stringgrid1.Cells[1,3]);
                           a3 := strtofloat ( stringgrid1.Cells[1,4]);
                           a4 := strtofloat ( stringgrid1.Cells[1,5]);
                           a5 := strtofloat ( stringgrid1.Cells[1,6]);
                           a6 := strtofloat ( stringgrid1.Cells[1,7]);
                           a7 := strtofloat ( stringgrid1.Cells[1,8]);
                           a8 := strtofloat ( stringgrid1.Cells[1,9]);

                           x0 := strtofloat ( stringgrid1.Cells[0,1]);
                           x1 := strtofloat ( stringgrid1.Cells[0,2]);
                           x2 := strtofloat ( stringgrid1.Cells[0,3]);
                           x3 := strtofloat ( stringgrid1.Cells[0,4]);
                           x4 := strtofloat ( stringgrid1.Cells[0,5]);
                           x5 := strtofloat ( stringgrid1.Cells[0,6]);
                           x6 := strtofloat ( stringgrid1.Cells[0,7]);
                           x7 := strtofloat ( stringgrid1.Cells[0,8]);
                           x8 := strtofloat ( stringgrid1.Cells[0,9]);


                           l0:= ((x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x5)*(x-x6)*(x-x7)*(x-x8))/ ((x0 - x1)* (x0 - x2)*(x0 - x3)*(x0 - x4)*(x0 - x5)*(x0 - x6)*(x0 - x7)*(x0 - x8));
                           l1:= ((x-x0)*(x-x2)*(x-x3)*(x-x4)*(x-x5)*(x-x6)*(x-x7)*(x-x8))/ ((x1 - x0)* (x1 - x2)*(x1 - x3)*(x1 - x4)*(x1 - x5)*(x1 - x6)*(x1 - x7)*(x1 - x8));
                           l2:= ((x-x0)*(x-x1)*(x-x3)*(x-x4)*(x-x5)*(x-x6)*(x-x7)*(x-x8))/ ((x2 - x1)* (x2 - x0)*(x2 - x3)*(x2 - x4)*(x2 - x5)*(x2 - x6)*(x2 - x7)*(x2 - x8));
                           l3:= ((x-x0)*(x-x1)*(x-x2)*(x-x4)*(x-x5)*(x-x6)*(x-x7)*(x-x8))/ ((x3 - x0)* (x3 - x1)*(x3 - x2)*(x3 - x4)*(x3 - x5)*(x3 - x6)*(x3 - x7)*(x3 - x8));
                           l4:= ((x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x5)*(x-x6)*(x-x7)*(x-x8))/ ((x4 - x1)* (x4 - x2)*(x4 - x3)*(x4 - x0)*(x4 - x5)*(x4 - x6)*(x4 - x7)*(x4 - x8));
                           l5:= ((x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x6)*(x-x7)*(x-x8))/ ((x5 - x1)* (x5 - x2)*(x5 - x3)*(x5 - x4)*(x5 - x0)*(x5 - x6)*(x5 - x7)*(x5 - x8));
                           l6:= ((x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x5)*(x-x7)*(x-x8))/ ((x6 - x1)* (x6 - x2)*(x6 - x3)*(x6 - x4)*(x6 - x5)*(x6 - x0)*(x6 - x7)*(x6 - x8));
                           l7:= ((x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x5)*(x-x6)*(x-x8))/ ((x7 - x1)* (x7 - x2)*(x7 - x3)*(x7 - x4)*(x7 - x5)*(x7 - x6)*(x7 - x0)*(x7 - x8));
                           l8:= ((x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x5)*(x-x6)*(x-x7))/ ((x8 - x1)* (x8 - x2)*(x8 - x3)*(x8 - x4)*(x8 - x5)*(x8 - x6)*(x8 - x7)*(x8 - x0));


                      p :=(a0*l0) + (a1*l1)+ (a2*l2)+ (a3*l3) + (a4*l4)+  (a5*l5)+ (a6*l6) + (a7*l7)+ (a8*l8);

                      edit4.Text := floattostr(p);

                           end;


procedure TForm3.Button4Click(Sender: TObject);
begin
   for i := 1 to stringgrid1.RowCount - 1 do
    begin
          stringgrid1.Cells [1,i] := inputbox('Input','Isi Data','') ;
        end;
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
        stringgrid1.Cells  [0,0]:='jumlah sagu';
        stringgrid1.Cells  [0,1]:='30';
        stringgrid1.Cells  [0,2]:='70';
        stringgrid1.Cells  [0,3]:='90';
        stringgrid1.Cells  [0,4]:='130';
        stringgrid1.Cells  [0,5]:='160';
        stringgrid1.Cells  [0,6]:='170';
        stringgrid1.Cells  [0,7]:='180';
        stringgrid1.Cells  [0,8]:='187';
        stringgrid1.Cells  [0,9]:='200';


         stringgrid1.Cells  [1,0]:='bioetanol';
         stringgrid1.Cells  [1,1]:='10';
         stringgrid1.Cells  [1,2]:='25';
         stringgrid1.Cells  [1,3]:='47';
         stringgrid1.Cells  [1,4]:='59';
         stringgrid1.Cells  [1,5]:='72';
         stringgrid1.Cells  [1,6]:='80';
         stringgrid1.Cells  [1,7]:='92';
         stringgrid1.Cells  [1,8]:='95';
         stringgrid1.Cells  [1,9]:='100';

end;

end.




Tampilan Formnya :




1 Response to "contoh script CURVE FITTING ordo n"