Octave Programming Tutorial/Sets

SET

Octave set operation There are different set operations in octave basically Octave can use vector, cell arrays or matrix as its set input operation.

1) SET UNION:

The set union operations is one of the operations where two sets a and b are merged together.

In this example we will took two set namely ,A with contents 1,2,3 and B with contents 3,4,5. First we are going to use the set union operation using Octave. This can be accomplished using the union function  available with octave.

2) SET INTERSECTION :

The set intersection operations is one of the operations where two sets a and b are merged together and common element is taken.

In this example we will took two set namely A  with contents 1,2,3 and b with contents 3,4,5 .First we are going to use the set intersection operation  using Octave. This can be accomplished using the intersection function  available with octave.

3) SET DIFFERENCE:

The set difference operations also called as the a-b operation is the operation which returns those element of a that are not in b. Lets write down the set difference operation as fallows :

Set=A-B

In this example we will took two set namely A with contents 1,2,3 and b with contents 3,4,5 First we are going to use the setdifference  operation  using Octave. This can be accomplished using the setdiff  function  available with octave. The difference operation is a Set operation in which those elements of a that are not in b are  returned.

4) UNIQUE:

The unique operation returns a set containing one copy of each element in the given set, and with the elements in sorted order.

In this example we will take a set namely A with contents 1,2,4,3,5,2,1 containing the duplicate elements 1 and 2, and elements out of order. The unique operation will sort the set and remove extra copies of the duplicated elements.

5) Ismember

The octave set ISMEMBER  is one the function in which two sets are compared and the  those elements that are present in the second set  are marked as true rest are marked as false. This function is basically used to check which element are present in both the set.