Create a nxn matrix with the same numbers on different rows

2 views (last 30 days)
Hi,
I have done extensive searching to find a way to create a matrix that has rows 1-4 be 1 number, row 5 be another number and then row 6-20 be a 3rd number. is there any easy way to do that or do i have to hand create the matrix?

Answers (1)

Star Strider
Star Strider on 28 Sep 2014
One way:
R14 = 3; % Choose numbers for various rows
R5 = 5;
R620 = 7;
M = zeros(20); % Preallocate
M(1:4,:) = R14;
M(5,:) = R5;
M(6:20,:) = R620;

Categories

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