How to reconstruct a matrix?
조회 수: 3 (최근 30일)
이전 댓글 표시
i have
x = [8, 9, -3, 9, 5, -4, -1, 3, 10, 10]
y = [-6; 4; 4; -2; 2]
z = diag(y)
how can i reconstruct matrix z into this look?
z =
-6 0 0 0 0 8
0 4 0 0 0 9
0 0 4 0 0 -3
0 0 0 -2 0 9
0 0 0 0 2 5
8 9 -3 9 5 -4
is there other way than this?
z = [-6 0 0 0 0 8; 0 4 0 0 0 9; 0 0 4 0 0 -3; 0 0 0 -2 0 9; 0 0 0 0 2 5; 8 9 -3 9 5 -4]
댓글 수: 1
Rik
2021년 5월 13일
Where are the lower values coming from? Do you just want to put the values of x on the lower and right edges?
What have you tried to put them there?
채택된 답변
Walter Roberson
2021년 5월 13일
x = [8, 9, -3, 9, 5, -4, -1, 3, 10, 10];
y = [-6; 4; 4; -2; 2];
z = [diag(y), x(1:5).'; x(1:6)]
댓글 수: 2
추가 답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!