How to collect the output in a matrix?

1 Ansicht (letzte 30 Tage)
Omar B.
Omar B. am 2 Jul. 2021
Kommentiert: Omar B. am 2 Jul. 2021
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);

Antworten (1)

KSSV
KSSV am 2 Jul. 2021
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 Kommentar
Omar B.
Omar B. am 2 Jul. 2021
Thank you, but how to constract the matrix T that contains Omegas in the diagonal and Gammas in off-diagonal?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by