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 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