![]() |
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:
Kann mir einer von euch sagen, wo der Fehler liegt? Schon mal Danke im Voraus .
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; |
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