MATLAB: Assign group labels to vectors of different and large lengths

anovagroup labels

I want to assign group labes to vectors of potentially different large lengths to apply anova1(Y,group).
for example if Y=[y1 y2] is a vector where length(y1)=100 and length(y2)=80, I would like to create a group vector of strings with one hundred 'a' and 80 'b', like so:
group=['a','a','a',....'a', 'b','b','b',....,'b']
So that all elements of vector y1 are will be corresponding to group 'a' and all elements of vector y2 with group 'b'.
I tried the following, but I get an error saying that 'Dimensions of arrays being concatenated are not consistent'.
y1=rand(100,1);
y2=rand(80,1);
Y=[y1 y2];
label1 = ['a'];
label2 = ['b'];
group1 = repmat(label1, length(y1), 1);
group2 = repmat(label2, length(y2), 1);
group=[group1 , group2];
[p,tbl,stats] =anova1(Y,group);
Any help is greatly appreciated.

Best Answer

Either:
group1 = repmat(label1, length(y1), 1);
group2 = repmat(label2, length(y2), 1);
group = [group1; group2];
% ^ ; instead of , for a vertical concatenation
or
group1 = repmat(label1, 1, length(y1)); % Create row vectors
group2 = repmat(label2, 1, length(y2));
group = [group1, group2];
I assume that if the data is a column vector, the group should be a column also, so the 1st approach is better.