Borrar filtros
Borrar filtros

Creating a specific lower rectangular matrix

1 visualización (últimos 30 días)
Amital
Amital el 24 de Feb. de 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

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by