필터 지우기
필터 지우기

Matrix symmetric by 2x2 blocks

조회 수: 1 (최근 30일)
Ohad Shapira
Ohad Shapira 2021년 1월 9일
편집: Ohad Shapira 2021년 1월 9일
Hello everyone,
I need to extract from 2n by 2n matrix the symetric and skew-symetric 2x2 blocks.
For example, for given A:
A=[
5,-1, 2,-3;
1,5, 4,2;
-2,3, 5,-1;
4,-2, 1,5;
]
I want to get:
A_symetric= [
5,-1, 0,0;
1,5, 4,0;
0,0, 5,-1;
4,0, 1,5;
]
And
A_skew_symetric= [
0,0, 2,3;
0,0, 0,2;
-2,-3, 0,0;
0,-2, 0,0;
]
  댓글 수: 2
Ohad Shapira
Ohad Shapira 2021년 1월 9일
function [A_sym,A_anti] = sym_by_blocks(A)
syms w t
n=length(A);
A_sym=sym(zeros(length(A)));
A_anti=sym(zeros(length(A)));
for row=1:2:n
for col=1:2:n
if row==col
A_sym(row:row+1,col:col+1)=A(row:row+1,col:col+1);
else
A_sym(row:row+1,col:col+1)=0.5*(A(row:row+1,col:col+1)+A(col:col+1,row:row+1));
A_anti(row:row+1,col:col+1)=0.5*(A(row:row+1,col:col+1)-A(col:col+1,row:row+1));
end
end
end
end
Image Analyst
Image Analyst 2021년 1월 9일
OK, and the question is.................
Or is that your answer?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Array and Matrix Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by