MATLAB code to create a pattern of matrix

Diagonal
for i=1 to 2n+2,
for j=1 to 2n+2,
aij=0 ; when i=j
end
1st row
for j= 2 to n+2
aij=1
for j=n+3 to 2n+2
aij=0
2nd row
for j=3 to n+2
a2j=0
for j=n+3 to 2n+2
a2j=1
3rd row
a34=-1, a3,n+3 = -1
for j=5 to n+2; n+4 to 2n+2
4th to n+1 rows
For i=4 to n+1
For j=1 to 2n+2 and i<j
When j=i+1
aij = -1
else aij=0
end
(n+2)th row
for i = n+2 and i<j
when j=2n+2
aij=-1
else aij= 0
(n+3 to 2n+1) rows
for i=n+3 to 2n+1 and i<j
when j=i+1
aij=1
else aij=0
lower diagonal elements
for i>j
aij=-aij

2 件のコメント

Rik
Rik 2021 年 2 月 24 日
It seems you already have an answer to your other question.
If you don't, please follow my advice there.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperating on Diagonal Matrices についてさらに検索

質問済み:

2021 年 2 月 24 日

コメント済み:

Rik
2021 年 2 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by