How can I insert elements in an array (a2) every nth place in (a1)
Example: Logic
a1 = [1,10,2,20,3,30,4,40,5,50];
a2 = [100,200,300,400,500];
n=3 % n would be the position to place the elements found in (a2) every **nth** position in (a1).
*n is the starting position at which the array a2 is inserted into a1*
The new a1 if n=3 after inserting a2 into it would look like
a1 = [1,10,100,2,20,200,3,30,300,4,40,400,5,50,500];
The new a1 if n=2 after inserting a2 into it would look like
a1 = [1,100,10,2,200,20,3,300,30,4,400,40,5,500,50];
The new a1 if n=1 after inserting a2 into it would look like
a1 = [100,1,10,200,2,20,300,3,30,400,4,40,500,5,50];
I tried
a1(1:3:end,:) = a2;
but I get dimensions mismatch error.
Please note this is just an example so I can't just calculate an answer I need to insert the data into the array. n is the starting position at which the array a2 is inserted into a1