Reputation: 2789
I have two vectors, one of them stores the width dimension of a set of images and another one the height of these set of images.
I want to use these values as two dimensional vectors [width height] and store them in a matrix. The first line, for instance, keeps the widths and the second line, the heights.
Is it possible to use the unique() function in matlab to return two dimensional unique values? I mean, the values can repeat in one dimension but the two dimensions cannot be the same as another vector?
How to do that in Matlab?
One example: given the following matrix, each column has a two dimensional vector. I want two dimensional unique vectors. The values can repeat in one dimension but not in both.
What I have:
[1,2,3,1;
4,5,6,4]
I want as output:
[1,2,3;
4,5,6]
Upvotes: 0
Views: 1418
Reputation: 5177
See docs for unique
.
Assuming widths
and heights
are column vectors,
[C,ia,ic] = unique([widths, heights],'rows')
In contrary, if widths
and heights
are row vectors,
[C,ia,ic] = unique([widths; heights].','rows')
Upvotes: 5