필터 지우기
필터 지우기

Diagonal matrix from multiple columns of an array

조회 수: 2 (최근 30일)
Saeid
Saeid 2018년 11월 4일
답변: Bruno Luong 2018년 11월 4일
I have the array
M=[a b c;
d e f;
g h i]
and I want to construct an array composed of several diagonal arrays in the form:
N=[0 a d 0 0;
0 0 b e 0;
0 0 0 c f;
g 0 0 0 0;
0 h 0 0 0]
or basically place the individual columns of M into pre-assigned positions (1 2 -3) in N. How can I do this without a loop?

채택된 답변

Bruno Luong
Bruno Luong 2018년 11월 4일
Take a look at spdiags

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by