Clear Filters
Clear Filters

How to merge two arrays/rearrange two table colums one by one

3 views (last 30 days)
Let's say I have tow arrays both are horizontal with the same size like:
I want to merge them so that the final array would be:
This was my first question. And the second question is similar to the first one so that I have (one row of the table):
table=[1,2,3,4,5,11,22,33,44,55] and I want to rearragne table columns so that I would have:

Accepted Answer

madhan ravi
madhan ravi on 2 Jul 2020
AB = reshape([A; B], 1, [])
Zeynab Mousavikhamene
Zeynab Mousavikhamene on 2 Jul 2020
Thank you. This one worked: AB = reshape([A'; B']', 1, [])
How about for table?
madhan ravi
madhan ravi on 2 Jul 2020
Edited: madhan ravi on 2 Jul 2020
clear table % naming a variable table is a terrible idea!!!
TAble = table;
TAble.a = [1,2,3,4,5,11,22,33,44,55];
TAble.a = reshape(reshape(TAble.a,5,[]).', 1, [])
whos TAble

Sign in to comment.

More Answers (0)


Find more on Matrices and Arrays in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!