InquilineKea
InquilineKea

Reputation: 891

How do I append the same row to each element of a 3D matrix?

a = ones(2,2,2)

a(:,:,1) =

 1     1
 1     1

a(:,:,2) =

 1     1
 1     1

I want to append ones(1,1) to the bottom row of each of a(:,:,1) and a(:,:,2)

Upvotes: 1

Views: 28

Answers (1)

yuk
yuk

Reputation: 19870

It's easy to do with CAT function:

 a = cat(1, a, ones(1,2,2));

or VERTCAT:

a = vertcat(a, ones(1,2,2));

Upvotes: 2

Related Questions