MATLAB: How to create a new table array combining the values every n,th element from two different table arrays

addtable

I have two table arrays with a big number of rows and one column each. Each array has a different size. I would like to add the values from the second array into the first so that every n values of A the same number of values of B are added to create a new table array C.
For example:
Given a matrix A=[2,5,7,9,11,13,15,17,19,21] and a matrix B= [1,1,1,1,1,1,3,3,3,3,3,3,4,4,4,4,4,6,6,6,6,6,6]
I would like to create a new matrix C = [2,5,1,1,1,1,1,7,9,3,3,3,3,3,3,11,13,4,4,4,4,4,15,17,6,6,6,6,6,6,19,21]
In this case every 2 values of A, 5 consecutive values from B are added.
In my case I would like to add every 60 values of A to add 59 consecutive values of B. The length of A is 2008×60= 120480 rows and B is 2008×59= 118472 rows.

Best Answer

In my case I would like to add every 60 values of A to add 59 consecutive values of B
So, assuming that A and B are indeed vectors
C = reshape([reshape(A, 59, []); reshape(B, 60, [])], 1, [])
Basically, reshape A in columns of 59 rows, reshape B in columns of 60 rows, concatenate the two matrices vertically and reshape back into a vector.