フィルターのクリア

How do i calculate the Number of records that exist in both tables?

2 ビュー (過去 30 日間)
ahmed obaid
ahmed obaid 2017 年 6 月 8 日
コメント済み: ahmed obaid 2017 年 6 月 9 日
Dear all,
I have two tables A and B .. where both tables have 5000 records , both tables have the following contents:
table A:-
Country name Code
USA 1
UK 1
RSA 2
KSA 3
etc..
Table B:-
Country name Code
USA 1
WSN 1
IRN 3
KSA 4
etc..
i need to calculate the following percentages: {per values for example 50%}
Per1=Percent of records that exist in Table A with similar code number as in Table B.
per2=percent of records that exist in Table A with different code number than in Table B.
Per3=Percent of records that exist in Table B with similar code number as in Table A.
per4=percent of records that exist in Table B with different code number than in Table A.
for example: number of records in table A with code number =1 is 75;
number of records in table A with similar code number =1 and similar to table B is 60;
then per1 = 60/75 * 100%;
etc. for others....
thanks for any help
  6 件のコメント
Image Analyst
Image Analyst 2017 年 6 月 9 日
Sorry, not until you help us help you. Remember when I asked "Attach the two table data files."? I'll check back later, perhaps tomorrow.
ahmed obaid
ahmed obaid 2017 年 6 月 9 日
Ok, i have attached my tables... for rows that not included in both .. eliminated .. thanks

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 6 月 9 日
編集済み: Andrei Bobrov 2017 年 6 月 9 日
A = readtable('A.xls');
B = readtable('B.xls');
na = size(A,1);
nb = size(B,1);
Per1 = sum(ismember(A,B))/na*100;
Per2 = sum(ismember(A{:,1},B{:,1}))/na*100 - Per1;
Per3 = sum(ismember(B,A))/nb*100;
Per4 = sum(ismember(B{:,1},A{:,1}))/nb*100 - Per3;
  1 件のコメント
ahmed obaid
ahmed obaid 2017 年 6 月 9 日
thank you very much ... very smart solution..

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by