How do I merge two data sets into one table when they don't match in the number of their rows.

1 次查看(过去 30 天)
I have two data sets that I'm trying to merge together. The first data set contains a quantity column. (ex. quantity of units = 3) and the second data set contains a row for each individual unit. Put simply, the second data set has much more rows than the first data set. What program can I write to extract all the rows from these data sets, and put them into a table (preferably in excel) so I can merge them together. Thanks so much for your input. Matlab is so great because of its incredible community.

采纳的回答

Walter Roberson
Walter Roberson 2011-6-7
Do you mean dataset as in a data type (such as from the statistics toolbox), or do you mean dataset as in simply an array of values?
Is there some kind of unit key shared between the two?
SecondSet(:,end+1) = 0; %create a new quantity column
[tf, idx] = ismember(FirstSet(:,IDColumn1),SecondSet(:,IDColumn2));
SecondSet(idx(tf),end) = FirstSet(tf,QuantityColumn);

更多回答(0 个)

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by