Efficiently importing data into a table based on a matching column value

1 回表示 (過去 30 日間)
Sean Bradley
Sean Bradley 2022 年 7 月 19 日
回答済み: Sulaymon Eshkabilov 2022 年 7 月 19 日
I have two large data tables. Each table has a column with a unique code representing the same event analyzed by two different pieces of software. Not all codes are present on both tables.
What I want to do is find rows in which the event in Table A matches the event code in Table B, and put other data from those matching rows alongside the data in tableA.
On a smaller scale, I've used something in the form of:
for q = 1:height(tableA)
for r = 1:height(tableB)
if tableA.frame(q) == tableB.frame(r)
tableA.data(q) = tableB.data(r);
end
end
end
Searching and replacing row-by-row is far too inefficient to use at scale and I'm sure there must be a better way, but since the tables are different sizes and each contains codes that aren't present on the other, I'm not sure how to do this via indexing in MATLAB.

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2022 年 7 月 19 日
Use setdiff()

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by