フィルターのクリア

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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by