How to collect the output in a matrix?

조회 수: 1 (최근 30일)
Omar B.
Omar B. 2021년 7월 2일
댓글: Omar B. 2021년 7월 2일
How can we create the block-tidaigonal matrix T using the output Omegas and Gammas as the picture I attached?
n=100;
k=2;
m=13;
A=rand(n,n);
A=A+A';
V=rand(n,k);
[V,B]=qr(V,0);
[n,k]=size(V);
Vs=cell(m+1,1);
Omegas=cell(m,1);
Rs=cell(m,1);
V0=zeros(n,k);
Gamma0=zeros(k,k);
Gammas=cell(m+1,1);
Vs{1}=V;
for j=1:m
if j==1
B=A*Vs{1};
else
B=A*Vs{j}-Vs{j-1}*Gammas{j-1}';
end
Omegas{j}=Vs{j}'*B;
Rs{j}=B-Vs{j}*Omegas{j};
[Vs{j+1},Gammas{j}]=qr(Rs{j},0);
end
%T=zeros(m*k,m*k);

답변 (1개)

KSSV
KSSV 2021년 7월 2일
n=100;
k=2;
m=13;
A=rand(n,n);
A=A+A';
V=rand(n,k);
[V,B]=qr(V,0);
[n,k]=size(V);
Vs=zeros(100,2,m+1);
Omegas=zeros(2,2,m) ;
Rs=zeros(100,2,m);
V0=zeros(n,k);
Gamma0=zeros(k,k);
Gammas=zeros(2,2,m+1);
Vs(:,:,1)=V;
for j=1:m
if j==1
B=A*Vs(:,:,1);
else
B=A*Vs(:,:,j)-Vs(:,:,j-1)*Gammas(:,:,j-1)';
end
Omegas(:,:,j)=Vs(:,:,j)'*B;
Rs(:,:,j)=B-Vs(:,:,j)*Omegas(:,:,j);
[Vs(:,:,j+1),Gammas(:,:,j)]=qr(Rs(:,:,j),0);
end
%T=zeros(m*k,m*k);
  댓글 수: 1
Omar B.
Omar B. 2021년 7월 2일
Thank you, but how to constract the matrix T that contains Omegas in the diagonal and Gammas in off-diagonal?

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

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by