Monday, July 23, 2012

"Set theory" operations in Scilab: union, intersection, and difference

In Scilab, there are 4 commands for "set theory":

1. Union operation of two data sets
2. Intersection of two data sets
3. Difference of two data sets
4. Unique elements of data set



Union operation is used in Scilab as the following (as Matlab)



The intersection of two data sets is computed like the following


The difference between two data sets  is computed like the following. You should remeber that difference is not commutative.


Finally, the unique command is used to get the unique elements of a data set with no repetition.

A thing to consider that all the results of set operations are row vectors. The inputs of set operations in Scilab can be matrices or vectors and they are automatically and internally converted to vectors to deal with.