Matlab - set like datatype?

45 Views Asked by At

I need to work with Matlab again but it's long ago that I did so the last time. So I need your help (searching for "set" leads only to how to set colors of axis and so...). How can I achieve a set like behavior of an array (or any other similar datatype).

The thing is I have a initial set of vectors and want to add some new vectors to it but I don't want doubles.

Thank you in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

Let Abe the $k\times n$ matrix containing your first vectors and v be the $1\times n$ vector you want to add in your "set" A. Then B = unique([A;v],'rows') will either output you B = A if v already belongs to A or B = [A;v] if v is a new vector of the set of vectors A.