I assume you want to fill values at each of the three occurrences of A
within B
.
If you don't mind repeating the vector v
:
B = repmat(A.',1,3); % easier to work by columns
B(bsxfun(@plus,find(mask.'),(0:2)*numel(A))) = v(repmat(1:numel(v),1,3)); % fill
B = B.'; % transpose back