フィルターのクリア

How Do i Sort rows in tables based on unique rows dictionary ?

1 回表示 (過去 30 日間)
ahmed obaid
ahmed obaid 2017 年 6 月 8 日
回答済み: Peter Perkins 2017 年 6 月 9 日
Dear experiences..
i have two tables.... A and B, where table A involves 4 columns as follow :
Table A:-
Id index con_name class
1 200 greed 1
2 301 rfg 3
3 505 rft 3
4 401 oil 1
etc..
Table B:-
con_name Var1 Var2 .......... VarN
rft ............................
greed ............................
rfg ............................
conr ...........................
oil ...........................
  • So ,my requirements as follow:
  • i need to build dictionary table includes only (con_name) that exist in both tables A and B.. then
  • remove con_name rows from Table A that not exist in dictionary table
  • remove con_name rows from Table B that not exist in dictionary table
  • sort con_name rows in table A and B in similar order.. where the result of table A and B shows that con_name in similar order.
i would thanks any one can help me in these requirements. thanks

採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 6 月 8 日
[l0,iB] = ismember(A.con_name,B.con_name);
dictionary_table = A{l0,3};
A_new = A(l0,:);
B_new = B(iB(l0),:);
[~,ii] = ismember(A_new.con_name,B_new.con_name):
B_new = B_new(ii,:);

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2017 年 6 月 9 日
This sounds a lot like one or more innerjoin operations.

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by