How to collect the output in a matrix?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!