Filter löschen
Filter löschen

Creating a specific lower rectangular matrix

1 Ansicht (letzte 30 Tage)
Amital
Amital am 24 Feb. 2012
Hello Matlab experts!
I'm interested in creating a specific lower rectangular matrix while avoiding loops.
Step 1: I create the following column vector:
[ A1 A2 A3 . . . . An ]'
Where n is a predetermined integer (changes from one simulation to another).
Step 2: I create the following matrix:
A1 A1 A1 A1 . . . . A1
A2 A2 A2 A2 . . . . A2
A3 A3 A3 A3 . . . . A3
. . .
An An An An . . . . An
Step 3: I want to perform the following shifts: Shift the second column one step down, Shift the third column two steps down, etc. So eventually I'll get the following matrix:
A1 An An-1 An-2 . . . . A2
A2 A1 An An-1 . . . . A3
A3 A2 A1 An . . . . A4
A4 A3 A2 A1 . . . . A5
. . .
An An-1 An-2 An-3 . . . . A1
Step 4: I use the 'tril' function to get the matrix I'm interested in, which is:
A1 0 0 0 . . . . 0
A2 A1 0 0 . . . . 0
A3 A2 A1 0 . . . . 0
A4 A3 A2 A1 . . . . 0
. . .
An An-1 An-2 An-3 . . . . A1
I need assistance with performing step 3.
Maybe there are better ways to create this matrix, let me know.
Thanks, Amital

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 24 Feb. 2012
A = 1:5;
out = tril(toeplitz(A))

Weitere Antworten (0)

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by