Tuesday, 7 June 2016

MATLAB Programming - Functions for set operations PROGRAM

Create a script file and type the following code:

a = [7 23 14 15 9 12 8 24 35]

b = [ 2 5 7 8 14 16 25 35 27]

u = union(a, b)

i = intersect(a, b)

s = setdiff(a, b)

When you run the file, it produces the following result:

a = 7 23 14 15 9 12 8 24 35

b = 2 5 7 8 14 16 25 35 27

u = Columns 1 through 11
      2 5 7 8 9 12 14 15 16 23 24
      Columns 12 through 14
      25 27 35

i = 7 8 14 35

s = 9 12 15 23 24

No comments:

Post a Comment