MATLAB: How to create a categorical variable with a specified number of characters

categorical variable

Hi, I am trying to create a vector called 'labels' which has 1883 'N's followed by 332 'A's. The code I am currently using just gives a string of N's and A's like this:
NNNNNNNAAAAAAA
However, I wanted to create a variable called 'labels' which has 2215 (2883 + 332) rows and 1 column like this:
[N; N; N; N; …. A; A; A]
Any help would be much appreciated, thanks in advance
% create a categorical variable with 1883 'N's' and 332 'A's'
labels(1:1883) = 'N';
labels(1884:2215) = 'A';

Best Answer

labels = [repmat('N',1883,1);repmat('A',332,1)];
or less robustly:
labels( 1:1883,1) = 'N';
labels(1884:2215,1) = 'A';
% ^^ added