Satimage Previous | Next
Removing data from a matrix
Home Documentation Smile Computing Smile's maths Removing data from a matrix  
You can remove rows from a matrix by applying a masking column.
  • To remove rows from a matrix according to some condition, build a mask and use the maskarray command. The mask must be an array of real with the same size as a column of the original matrix (nrows) filled with only 0's and 1's. Usually you make a mask by using evalformula with a boolean expression.
    maskarray removes the rows which correspond to the 0.0 value in the mask.
    set b to {0.0, 1.0, 10.0, 11.0, 20.0, 21.0} as array of real
    set c to ArrayToMatrix(b, 2, 3)
    set m to {0.0, 1.0, 1.0}
    set d to maskarray c with m
    display d
      --  Result:
    10.000000    11.000000
    20.000000    21.000000
  • Since {a, b, c} as matrix returns the matrix with columns a, b and c, the operations maskarray and as matrix commute.
    (maskarray {a, b, c} with mk) as matrix
      -- is the same matrix as
    maskarray ({a, b, c} as matrix) with mk
Version française
Copyright ©2008 Paris, Satimage