# How to match two matrices based on two keys?

1 visualizzazione (ultimi 30 giorni)
Mohamed Nedal il 10 Gen 2020
Risposto: Hiro Yoshino il 10 Gen 2020
Hello everyone,
Kindly find the attached file. I would like to know how to match these matrices based on two keys rather than one key?
I tried this code and for only one key (time).
xCOL = {'DOY','UT','lat','long'};
yCOL = {'DOY','UT','pf_30Mev','pf_60Mev'};
for i = 1:length(X)
X = array2table(X,'VariableNames',xCOL);
Y = array2table(Y,'VariableNames',yCOL);
output = innerjoin(X,Y,'LeftKeys','UT','RightKeys','Hour');
writetable(output, 'Matched.xlsx', 'Sheet', i);
end
The 1st column represents the day of year (DOY) and the 2nd column represents the time in hours.
I want to find the rows at which both the day and time of X and Y are the same.
Can you please tell me how?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Hiro Yoshino il 10 Gen 2020
The script below worked for me where "DOY" and "UT" were used as keys:
xCOL = {'DOY','UT','lat','long'};
yCOL = {'DOY','UT','pf_30Mev','pf_60Mev'};
X = array2table(X,'VariableNames',xCOL);
Y = array2table(Y,'VariableNames',yCOL);
output = innerjoin(X, Y,'Keys',[1 2]);
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Pulse and Transition Metrics in Help Center e File Exchange

R2017b

### Community Treasure Hunt

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

Start Hunting!

Translated by