Create triangular matrix from vector

조회 수: 16 (최근 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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by