MATLAB: I want to replace cell data to index.

cellfun replace cell

Hello,
I'm poor at English so write simple code..
cell data is a = {[1 2 3 4 ] [5 6] [ 7 8 9]} ; index = [2 1 3] ; -> 10 11 12
the result is a = {[1 10 3 4] [ 11 6] [7 8 12 ]}
cell data size are different.
i want to replace the cell data at the same time. How can i replace the data without using for loop. i don't know how to use cellfun function or another method.
for example,
at matrix a = [1 2 3 4 5] ; a([1 3]) = [100 200 ] ; the result is a=[100 2 200 4 5] ;
i want like this at cell.
thanks.

Best Answer

I think this is the best way:
a = {[1 2 3 4 ] [5 6] [ 7 8 9]} ;
index = [2 1 3] ;
b=[10 11 12];
for k=1:numel(a)
a{k}(index(k))=b(k);
end
celldisp(a)