How to match two matrices based on two keys?

1 回表示 (過去 30 日間)
Mohamed Nedal
Mohamed Nedal 2020 年 1 月 10 日
回答済み: Hiro Yoshino 2020 年 1 月 10 日
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?

回答 (1 件)

Hiro Yoshino
Hiro Yoshino 2020 年 1 月 10 日
The script below worked for me where "DOY" and "UT" were used as keys:
load("matlab.mat");
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]);

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by