How to collect the output in a matrix?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
KSSV
el 2 de Jul. de 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);
Ver también
Categorías
Más información sobre Particle & Nuclear Physics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!