MATLAB: How to create the array [1, 2,2 ,3, 3, 3, 4,4 4, 4]

arrayhomeworkMATLAB

I would like to create an array that increases in repeated value with each as shown in the title
[1,2,2,3,3,3,4,4,4.,.]

Best Answer

>> V = 1:10;
>> floor(sqrt(2*V)+1/2)
ans =
1 2 2 3 3 3 4 4 4 4