Find the symmetric and skew-symmetric matrices by 2x2 blocks

3 ビュー (過去 30 日間)
Ohad Shapira
Ohad Shapira 2021 年 1 月 8 日
コメント済み: Matt J 2021 年 1 月 10 日
Hello everyone,
I need to extract from 2n by 2n matrix the symetric and skew-symetric 2x2 blocks:
For example, for given A:
A=[
0,-1, 2,3;
1,0, 4,2;
-2,3, 0,-1;
4,-2, 1,0;
]
I want to get:
A_symetric= [
0,-1, 0,3;
1,0, 4,0;
0,3, 0,-1;
4,0, 1,0;
]
And
A_skew_symetric= [
0,0, 2,0;
0,0, 0,2;
-2,0, 0,0;
0,-2, 0,0;
]
  1 件のコメント
Matt J
Matt J 2021 年 1 月 10 日
It is unclear why you consider A_symmetric to be blockwise symmetric. The 2x2 submatrix
0,3,
4,0,
is not symmetric.

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

回答 (1 件)

Matt J
Matt J 2021 年 1 月 8 日
編集済み: Matt J 2021 年 1 月 8 日
A=[
0,-1, 2,3;
1,0, 4,2;
-2,3, 0,-1;
4,-2, 1,0;
];
n=length(A)/2;
mask = (-1).^( (1:2*n).' + (1:2*n) )==-1;
A_symetric=A.*(mask)
A_symetric = 4×4
0 -1 0 3 1 0 4 0 0 3 0 -1 4 0 1 0
A_skew_symmetric=A.*(~mask)
A_skew_symmetric = 4×4
0 0 2 0 0 0 0 2 -2 0 0 0 0 -2 0 0
  1 件のコメント
Ohad Shapira
Ohad Shapira 2021 年 1 月 9 日
編集済み: Ohad Shapira 2021 年 1 月 9 日
In a simple change this solution does not hold...
A=[
5,-1, 2,3;
1,5, 4,2;
-2,3, 5,-1;
4,-2, 1,5;
];
I get:
A_skew_symmetric =
5 0 2 0
0 5 0 2
-2 0 5 0
0 -2 0 5
The diagonal is always symetric

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

カテゴリ

Help Center および File ExchangeSpecialized Power Systems についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by