Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Image Analyst
Image Analyst il 9 Giu 2017
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 il 9 Giu 2017
Ok, i have attached my tables... for rows that not included in both .. eliminated .. thanks

Accedi per commentare.

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 9 Giu 2017
Modificato: Andrei Bobrov il 9 Giu 2017
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;

Più risposte (0)

Categorie

Scopri di più su WSNs in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by