PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Adding two matrices of same dimensions
Adding two matrices of same dimensions
The following code is used to add two matrices.
In this example, we will assume that the matrices are already created. The existence of the matrices is checked by MatExist. The matrices must have the same dimensions (same number of columns checked by MatNbColumn, same number of rows checked by MatNbLine).
// --Click code on BTN_Add
// Declare the variables
ResAdd is boolean
// Checks the existence of the matrices
IF MatExist("Matrix1") = True AND MatExist("Matrix2") = True THEN
// Same number of rows?
IF MatNbLine("Matrix1") = MatNbLine("Matrix2") THEN
// Same number of columns?
IF MatNbColumn("Matrix1") = MatNbColumn("Matrix2") THEN
// Add the two matrices
ResAdd = MatAdd("Matrix1", "Matrix2", "MatrixResult")
IF ResAdd = True THEN
Info("The addition was performed")
ELSE
// Display the error message
Error(ErrorInfo(errMessage))
END
ELSE
Info("The matrices do not have the same number of columns")
END
ELSE
Info("The matrices do not have the same number of rows")
END
ELSE
Info("The matrices do not exist")
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment