필터 지우기
필터 지우기

I'm trying to solve christoffel symbol in Matlab. Code is not working.

조회 수: 4 (최근 30일)
Muhammad Salahul Din
Muhammad Salahul Din 2017년 12월 4일
답변: Chris Jennings 2021년 5월 30일
syms th d alpha a th1 th2 l1 l2 lc1 lc2 I1x I1y I2x I2y I1z I2z m1 m2 Gamma
D=[m1*lc1^2+m2*(l1^2+lc2^2+2*lc2*l1*cos(th2))+I1z+I2z m2*(lc2^2+l1*lc2*cos(th2))+I2z; m2*(lc2^2+l1*lc2*cos(th2))+I2z m2*(lc2^2)+I2z];
d(1,1)=D(1,1); d(1,2)=D(1,2); d(2,1)=D(2,1); d(2,2)=D(2,2);
n=2;
for gamma = 1:n
for beta = 1:n
for alpha = 1:n
Gamma (gamma, beta, alpha) = 0.5 * ...
(diff (d(alpha, beta), th(gamma)) + ...
diff (d(alpha, gamma), th(beta)) - ...
diff (d(gamma, beta), th(alpha)));
end
end
end
Gamma (:, :, gamma)

답변 (2개)

Elizabeth Reese
Elizabeth Reese 2017년 12월 6일
I believe this is just an issue with trying to index into a symbolic value that was not declared as a vector. I was able to run this by adding the following line between the assignment to n and the loops.
th = sym('th',[n,1]);
You can read about how to declare symbolic vectors here.
You can do the same type of creation for Gamma to eliminate the warning about Gamma changing size each iteration.

Chris Jennings
Chris Jennings 2021년 5월 30일

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by