How do I horizontally concatenate the following 2 numerical arrays?
Show older comments
I have 2 separate arrays that I'm trying to concatenate.
ND is a 2x6 double array as follows;
ND = 58560 NaN 58561 -1100 -5100 4100
58570 Nan 59571 -1200 -5200 4200
OD is a 3x4 double array as follows;
OD = 58564 1 58563 11
58572 2 58573 21
58572 2 58573 22
The desired output array is shown below (3x 10 double array):
output = 58560 NaN 58561 -1100 -5100 4100 58564 1 58563 11
58570 NaN 59571 -1200 -5200 4200 58572 2 58573 21
58570 NaN 59571 -1200 -5200 4200 58572 2 58573 22
Since the dimensions do not allow for either vertical or horizontal concatenation, is there a technique I could use to achieve the desired output?
Accepted Answer
More Answers (1)
Andrei Bobrov
on 27 Nov 2013
out = [ND(OD(:,2),:),OD]
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!