Create triangular matrix from vector

13 ビュー (過去 30 日間)
Sib RV
Sib RV 2021 年 7 月 8 日
コメント済み: Sib RV 2021 年 7 月 8 日
I have a vector, v = [x1, x2, x3 ....,xn]
I want to create a matrix from it in two ways: Upper triangular
x1 x2 x3.... xn
0 x2 x3 .... xn
0 0 x3 .....xn
. . . . . . ...
0 0 0 . . . . xn
Next, lower triangular:
x1 0 0 . .. 0
x1 x2 0 .... 0
. . . . .
x1 x2 .........xn
How can I do it without loops and conditional statements ?
Thank you.
  2 件のコメント
Scott MacKenzie
Scott MacKenzie 2021 年 7 月 8 日
This looks like a homework question. Have you tried any possible solutions? Please post what you have tried and ask a specific question about what you don't understand.
Sib RV
Sib RV 2021 年 7 月 8 日
It is already answered here. https://www.mathworks.com/matlabcentral/answers/114517-transforming-vector-into-triangular-matrix?s_tid=answers_rc1-1_p1_MLT

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

採用された回答

KSSV
KSSV 2021 年 7 月 8 日
REad about triu and tril.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by