You can convert cell array to indices with grp2idx
, then use meshgrid
, then strcat
to combine strings. Before you also need to convert numeric Months2
vector to cell array of strings.
[id1,id2] = meshgrid(grp2idx(Months1),Months2);
Months2cell = cellstr(num2str(id2(:)-2000,'%02d'))';
Combined = strcat( Months1(id1(:)), Months2cell );