Defining a matrix of moving constants using a loop

Hello everyone,
i want to define a matrix of size nxn with first row having 5 constants i.e. A(1,1:5) are constants..other coefficients are zeros...and then put start these constants from the second column in the second row...this going for n rows...for eg
if I have A (1,:) = [1 2 3 4 5 0 0 ... n0] as the first row,
the next row would be
A (2,:) = [0 1 2 3 4 5 0 ..0 0 n0]
this goes on until
A (n,:) = [0 0 ... 0 1 2 3 4 5]
i presume this is a looping issue...can any one guide how would I define this loop?
Thanks in advance for your help

Answers (1)

A = 1:5
n = 4
B = triu(toeplitz(A, [A zeros(1,n)]))

This question is closed.

Asked:

on 4 Jun 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!