フィルターのクリア

Creating a specific lower rectangular matrix

1 回表示 (過去 30 日間)
Amital
Amital 2012 年 2 月 24 日
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

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 2 月 24 日
A = 1:5;
out = tril(toeplitz(A))
  1 件のコメント
Amital
Amital 2012 年 2 月 24 日
Toeplitz! ofcourse!! thanks a lot . . .

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by