I'd use findgroups. First let's define the data.
x = ["A-00555"; "A-01139"; "B-08811"; "B-00014"; "C-00007"; ...
"C-00007"; "D-00015"; "D-00015"; "E-00048"; "E-00048"; "E-00048"];
y = categorical(["APPLE"; "GRAPEFRUIT"; "COCONUT"; "APPLE"; "APPLE"; ...
"BANANA"; "APPLE"; "COCONUT"; "APPLE"; "BANANA"; "KIWI"]);
Now use findgroups to get the group numbers for each element in x.
join the elements of y (converted to string) in each group, putting a + between the elements.
s = splitapply(@(x) join(string(x), "+"), y, g);
Let's see the results as a table.
Best Answer