How to collect the output in a matrix?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponses (1)
KSSV
le 2 Juil 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);
Voir également
Catégories
En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!