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

1 次查看(过去 30 天)
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
Use setdiff()

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by