How to rearrange matrix and delet similar value ?

2 ビュー (過去 30 日間)
Mech
Mech 2014 年 6 月 16 日
コメント済み: Andrei Bobrov 2014 年 6 月 17 日
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

採用された回答

Andrei Bobrov
Andrei Bobrov 2014 年 6 月 16 日
編集済み: Andrei Bobrov 2014 年 6 月 17 日
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.
  2 件のコメント
Mech
Mech 2014 年 6 月 16 日
out =
0 0 10 125 150 150
0 70 80 80 0 55
thank you very much andrei
  1. Can you explane the command more than
  2. Can you add to command to put the value according 2nd line when the value of 1st line is same to have result like this :
0 0 10 125 150 150
0 70 80 80 55 0
Andrei Bobrov
Andrei Bobrov 2014 年 6 月 17 日
Please see code in my answer after word 'add'.

サインインしてコメントする。

その他の回答 (1 件)

Mech
Mech 2014 年 6 月 16 日
Andrei Bobrov waiting you :)
  5 件のコメント
Mech
Mech 2014 年 6 月 16 日
Dosent work
José-Luis
José-Luis 2014 年 6 月 16 日
That's not a very useful statement, I'm afraid. You could always google, as all the documentation is online.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by