Subtracts all elements in two (one- or two-dimensional) floating point arrays.
Mat Sub a()=b()-c()or
Mat Sub a(),b() or
Mat Sub a(),x
a(), b(), c():names of one- or two-dimensional floating point arrays
x:aexp
Mat Sub a()=b()-c() is only valid for floating point arrays of the same order, such as Dim a(n, m),b(n, m),c(n, m) or Dim a(n),b(n),c(n). The contents of elements in array c() are subtracted from the contents of elements in array b() and the result is written to array a().
Mat Sub a(),b() subtracts the contents of elements in array b() from the elements in array a() and writes the result to array a(). The original array a() is thereby lost.
Mat Sub a(),x subtracts the expression x from the contents of all elements in array a() and writes the result to array a(). The original array a() is thereby lost.
OpenW 1 : Win_1.FontName = "terminal"
Global Double a(1 To 3, 1 To 5)
Global Double b(1 To 3, 1 To 5)
Global Double c(1 To 3, 1 To 5)
Mat Set b() = 3
Mat Set c() = 4
Mat Print b(), 2, 0
divide(14, "Minus")
Mat Print c(), 2, 0
divide(14, "Equals")
Mat Sub a() = b()-c()
Mat Print a(), 2, 0
Print : Print : Print
Erase a(), b(), c()
Dim a(3, 5), b(3, 5), c(3, 5)
Mat Set b() = 3
Mat Set c() = 4
Mat Print b(), 2, 0
divide(17, "Minus")
Mat Print c(), 2, 0
divide(17, "Equals")
Mat Sub a() = b()-c()
Mat Print a(), 2, 0
Erase a(), b(), c()
Sub divide(n%, n$)
Print String(n%, "-"); : Trace Win_1.CurrentX
Text (CurrentX - TextWidth(n$ & " ")) / 2, CurrentY, " " & n$ & " "
Print : Print
EndSub
Example 2
OpenW 1 : Win_1.FontName = "terminal"
Global Double a(1 To 3, 1 To 5), x%
Global Double b(1 To 3, 1 To 5)
Mat Set a() = 1
Mat Set b() = 3
Mat Print a(), 2, 0
divide(14, "Minus")
Mat Print b(), 2, 0
divide(14, "Equals")
Mat Sub a(), b()
Mat Print a()
Erase a(), b()
Sub divide(n%, n$)
Print String(n%, "-"); : Trace Win_1.CurrentX
Text (CurrentX - TextWidth(n$ & " ")) / 2, CurrentY, " " & n$ & " "
Print : Print
EndSub
Example 3:
OpenW 1
Win_1.FontName = "Terminal"
Global Double a(1 To 3, 1 To 5), x%
Mat Set a() = 1
Mat Print a(), 2, 0
Print String$(14, "-")
Mat Sub a(), 5
Mat Print a()
-
{Created by Sjouke Hamstra; Last updated: 15/10/2014 by James Gaite}