Add 2d array in a 3d array

20 views (last 30 days)
Alan De maman
Alan De maman on 6 Nov 2020
Commented: Alan De maman on 6 Nov 2020
I have a matrix A = rand(10,5,10) and a matrix B = rand(10,10) and i would like to concatenate then along the second axis into a matrix C of shape (10,6,10)
  2 Comments
Sindar
Sindar on 6 Nov 2020
try:
C = A;
C(:,6,:) = B;
Alan De maman
Alan De maman on 6 Nov 2020
Thank you Sindar, it worked as expected.

Sign in to comment.

Answers (0)

Categories

Find more on Creating and Concatenating Matrices 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!