ProductName  

Creates a new matrix object that represents the result of subtracting another matrix from the current matrix object.

Syntax

MatrixObject.Minus(MatrixToSubtract)

Return Value

Returns a reference to the matrix resulting from the subtraction.

Parameters

MatrixToSubtract
The matrix that you wish to subtract from current matrix.

Remarks

Both matrices must be of the same size (Rows and Cols properties must be equal).

Error Codes

Error 1312 will be returned if the matrices are not of the same size.

Example

This example demonstrates the use of the Plus and Minus methods.

Private Sub MatrixPlusMinus()

Dim A As Matrix, B As Matrix

    Set A = New Matrix
    A.Size 5, 5
    A.FillRandom
    Debug.Print "A ="
    Debug.Print A.GetString(0)
    
    Set B = New Matrix
    B.Size 5, 5
    B.FillRandom
    Debug.Print "B ="
    Debug.Print B.GetString(0)
    
    Debug.Print "A + B = "
    Debug.Print A.Plus(B).GetString(0)
    Debug.Print "A - B = "
    Debug.Print A.Minus(B).GetString(0)
 
End Sub

Output

A =
|  6  2  8  6  5 |
|  4  9  8  7  2 |
|  9  7  5  3  0 |
|  1  4  1  2 10 |
|  4  1  0  0  4 |

B =
|  6  6  6  2  7 |
|  5  4  1  6  8 |
|  8  5  3  9  7 |
| 10  9  5  1  5 |
|  2  9  2  8  8 |

A + B = 
| 12  8 14  8 12 |
|  9 13  9 13 10 |
| 17 12  8 12  7 |
| 11 13  6  3 15 |
|  6 10  2  8 12 |

A - B = 
|  0 -4  2  4 -2 |
| -1  5  7  1 -6 |
|  1  2  2 -6 -7 |
| -9 -5 -4  1  5 |
|  2 -8 -2 -8 -4 |

See Also

Plus Method | PlusEquals Method | MinusEquals Method

Applies To: Matrix | CMatrix