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

1 view (last 30 days)
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);
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.

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 19 Jul 2022
Use setdiff()


Find more on Tables in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!