MATLAB: How to rearrange matrix and delet similar value

how to rearrange matrix and delet similar value

Hi guys
I have matrix and should rearrange matrix and delete similar value as next:
the origin matrix
0 0 10 150 150 0 125 150 0 10 125 150
0 0 80 0 0 70 80 55 70 80 80 55
what I need
0 0 10 125 150 150
0 70 80 80 55 0
What's program i need hould do:
  1. when values of column are similar then delete column that repeated
  2. rearrange column according first line

Best Answer

a=[ 0 0 10 150 150 0 125 150 0 10 125 150
0 0 80 0 0 70 80 55 70 80 80 55]
out = unique(a.','rows')'
add
a0 = unique(a.','rows');
t = ismember(a0(:,1),a0(size(a0,1),1));
a0(t,2) = sort(a0(t,2),'descend');
out = a0.';
Please read about functions unique, size, ismember, sort.