user25004
user25004

Reputation: 2048

concatenating matrices a variable number of times in Matlab

How can I write this is one command in Matlab (or without loop)

X=A;
for i =1:d-1
    X= cat(3, X, A);
end

I tried to use permute, and then repmat, but the singleton last dimension is eliminated automatically, so that does not help.

Upvotes: 0

Views: 55

Answers (1)

Alexandre Willame
Alexandre Willame

Reputation: 455

Use the repmat function (see repmat doc)

X = repmat(A, [size(A), d])

Upvotes: 1

Related Questions