This question is really unclear. The best I can guess is that you want to assign S into specified rows of one variable in a table that's been pre-allocated with all NaN.
The first thing, as I said in at least one other thread, is that you should stay away from cell arrays. All you have are numbers.
The second thing is don't name one of your variables "table".
The following does what my best guess is at what you want:
>> i =[5;6;7;12;13;14;16;17;18];
>> S =[1,1,1,1,1,1,1,0,1];
>> t = array2table(nan(20,3));
>> t.Var1(i) = S
t =
20×3 table
Var1 Var2 Var3
____ ____ ____
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN
1 NaN NaN
1 NaN NaN
1 NaN NaN
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN
NaN NaN NaN
1 NaN NaN
1 NaN NaN
1 NaN NaN
NaN NaN NaN
1 NaN NaN
0 NaN NaN
1 NaN NaN
NaN NaN NaN
NaN NaN NaN
Best Answer