MATLAB: Find the Unique Coupled-value in a vector and eliminate the zero-coupled values

coupledunique

Hello everybody,
Thank you for the interest for my question and your help I am not successful to find an algorithm which permits to get unique coupled-values in a two-rows vector. Here is the example:
vect=[
1 599 256 599 256 0 0 0 0 0 324 599 256 256 599
171 171 150 171 150 150 171 0 0 0 171 150 0 171 150
]
The results that I want is
res=
[
1 599 256 0 0 324 599 256 256
171 171 150 150 171 171 150 0 171
]
Could you please provide an algorithm for me ?
Thanks in advance,
gringoire lee

Best Answer

[a b c] =unique(vect','rows','first')
out = sortrows([a,b],3)
res = out(any(out(:,1:2),2),1:2)'