Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Matrizen-Addition (https://www.delphipraxis.net/93939-matrizen-addition.html)

krutho 13. Jun 2007 16:35


Matrizen-Addition
 
Hallöchen erstmal. Bin neu hier und absoluter Delphi-Laie.
Ich hab da ein Problem mit einem Programm. Es sollte zwei Matrizen(Stringgrids) als
2D-Arrays einlesen, summieren und in ein drittes Stringgrid einfügen. Jedoch bekomme
ich hierbei eine Fehlermeldung:

" " Ist kein gültiger Gleitkommawert"

Hier nun der Quelltext

Delphi-Quellcode:
procedure TForm2.Matrixadd(Sender:TObject);

var  matrixA: array of array of double;
      matrixB: array of array of double;
      matrixC: array of array of double;
      n,m,x,y:integer;


begin
      n:=StrToInt(EditN.Text);
      m:=StrToInt(EditM.Text);
      SetLength(matrixA,m,n);
      SetLength(matrixB,m,n);
      SetLength(matrixc,m,n);
      For x:= 0 to m-1 do
        for y:= 0 to n-1 do
          matrixA[x,y]:=StrToFloat(SG1.Cells[x,y]);
          MatrixB[x,y]:=StrToFloat(SG2.Cells[x,y]);
          matrixc[x,y]:=(matrixA[x,y])+(matrixB[x,y]);
          SG3.Cells[x,y]:=FloatToStr(matrixc[x,y]);


end;
Kann mir einer von euch sagen, wo der Fehler liegt? Schon mal Danke im Voraus .

Amateurprofi 13. Jun 2007 16:42

Re: Matrizen-Addition
 
Delphi-Quellcode:
For x:= 0 to m-1 do
   for y:= 0 to n-1 do begin
       matrixA[x,y]:=StrToFloat(SG1.Cells[x,y]);
       MatrixB[x,y]:=StrToFloat(SG2.Cells[x,y]);
       matrixc[x,y]:=(matrixA[x,y])+(matrixB[x,y]);
       SG3.Cells[x,y]:=FloatToStr(matrixc[x,y]);
   end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:51 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz