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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Jun. de 2011
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);

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by