I'm trying to solve christoffel symbol in Matlab. Code is not working.
8 views (last 30 days)
Show older comments
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)
0 Comments
Answers (2)
Elizabeth Reese
on 6 Dec 2017
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 do the same type of creation for Gamma to eliminate the warning about Gamma changing size each iteration.
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!