MATLAB: How to create such a matrix like this

matrix creation

Hello,
I need to create a matrix as following:
Number of the rows depend on 'i', where i=3 and number of columns depend on i*s, where s=12 in this example.
There are 12 ones in each row(in this example), all others are zero.
1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
I need a code to generate this matrix appropriate for all i and s values.
Thanks for help!

Best Answer

i = 3;
s = 12;
M = zeros(i,i*s);
for n = 1:i
M(n,(n-1)*s+1:n*s) = 1;
end