I\'m trying to insert a value to a vector at specific indices, specified in another vector, and then displacing the other values accordingly.
E.g.
Here is a general function. The idea is the same as @Mark said:
function arrOut = insertAt(arr,val,index)
assert( index<= numel(arr)+1);
assert( index>=1);
if index == numel(arr)+1
arrOut = [arr val];
else
arrOut = [arr(1:index-1) val arr(index:end)];
end
end
I have never heard of a built-in function for this.