Muaaz Khalid
Muaaz Khalid

Reputation: 2249

Find difference between two Matrix/Vectors in matlab

I have two matrix and want to get difference(Subtraction) b/w two matrix

e.g, IF

A = [2 4 6]
B = [1 1 1]

Answer should be

ans = [1 3 5]      % A-B

Note: (Its not a set difference..)

Upvotes: 1

Views: 9769

Answers (1)

herohuyongtao
herohuyongtao

Reputation: 50657

Just use one of the following in Matlab:

  1. A-B
  2. minus(A,B)

You will get:

ans =

    1     3     5

Check out here for more info.

Upvotes: 6

Related Questions