How to Create a 5x5 matrix whose rows are (1:5)?

 Accepted Answer

You can do that with simple vector multiplication:
A = ones(5, 1) * (1:5);

More Answers (1)

KL
KL on 6 Sep 2017
Edited: KL on 6 Sep 2017
A = repmat(1:5,5,1);
or in general,
N = 5;
A = repmat(1:N,N,1)

Categories

Find more on Operators and Elementary Operations 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!