初学matlab ,克赖斯基矩阵分解,程序哪里错误function [L,L']=myLL'(A)[n,n]=size(A);L=zeros(size(A));L'=zeros(size(A));L(1,1)=sqrt(A(1,1));L(2:end,1)=A(2:end,1)/L(1,1);for j=2:nfor i=j+1:nL(j,j)=sqrt(A(j,j)-L(j,1:j-1)*L(j,1:j-1));L(i,j)=(A

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/13 04:30:07

初学matlab ,克赖斯基矩阵分解,程序哪里错误function [L,L']=myLL'(A)[n,n]=size(A);L=zeros(size(A));L'=zeros(size(A));L(1,1)=sqrt(A(1,1));L(2:end,1)=A(2:end,1)/L(1,1);for j=2:nfor i=j+1:nL(j,j)=sqrt(A(j,j)-L(j,1:j-1)*L(j,1:j-1));L(i,j)=(A
初学matlab ,克赖斯基矩阵分解,程序哪里错误
function [L,L']=myLL'(A)
[n,n]=size(A);
L=zeros(size(A));
L'=zeros(size(A));
L(1,1)=sqrt(A(1,1));
L(2:end,1)=A(2:end,1)/L(1,1);
for j=2:n
for i=j+1:n
L(j,j)=sqrt(A(j,j)-L(j,1:j-1)*L(j,1:j-1));
L(i,j)=(A(i,j)-L(i,1:j-1)*L(j,1:j-1))/L(j,j);
L'(i,j)=L(j,i);
end
end
L,L'

初学matlab ,克赖斯基矩阵分解,程序哪里错误function [L,L']=myLL'(A)[n,n]=size(A);L=zeros(size(A));L'=zeros(size(A));L(1,1)=sqrt(A(1,1));L(2:end,1)=A(2:end,1)/L(1,1);for j=2:nfor i=j+1:nL(j,j)=sqrt(A(j,j)-L(j,1:j-1)*L(j,1:j-1));L(i,j)=(A
你的代码错误太多, 我懒得一一指出了,直接给你一个样例,你自己对比
function L = myLL(A)
n = size(A, 1);
for i = 1:n-1,
A(i,i) = sqrt(A(i,i));
A(i+1:end,i) = A(i+1:end,i)/A(i,i);
A(i+1:end,i+1:end) = A(i+1:end,i+1:end)-A(i+1:end,i)*A(i+1:end,i)';
end
A(n,n) = sqrt(A(n,n));
L = tril(A);