Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Symsum and matrix usage error

조회 수: 1 (최근 30일)
Berke Ogulcan Parlak
Berke Ogulcan Parlak 2019년 11월 5일
마감: MATLAB Answer Bot 2021년 8월 20일
Screenshot_1.png
I need to write this algorithm, but I get an error like this:
Screenshot_2.png
This is my code:
A=[2,4,5;6,7,8;10,12,4];
n = length(A);
syms k
for i=1:n
for j=i+1:n
R(i,i)=sqrt(A(i,i)-symsum(R(k,i)^2,k,1,i-1));
R(i,j)=(A(i,j)-symsum(R(k,i)*R(k,j),k,1,i-1))/R(i,i);
end
end

답변 (1개)

Walter Roberson
Walter Roberson 2019년 11월 5일
It is never possible to use a symbolic variable as a subscript.
sum(u(1:i-1,i).*u(1:i-1,k))
If you need to generalize this to multiple i values then you should look at techniques such as using tril() and matrix multiplication.

Community Treasure Hunt

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

Start Hunting!

Translated by