Why bad partial differentiation?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I've a problem with this:
input parameter to my function is degree-it's number
There is a reason why I need m0,phi0 and not l0
m=sym('m',[1,degree]);
m=[m0 m];
l=sym('l',[degree,1]);
phi=sym('phi',[1,degree]);
phi=[phi0 phi] ;
for i=1:length(phi)
phi(i)=strcat(char(phi(i)),'(t)');
end
B=(1/2)*l(1)*m(2)*diff(phi(1),t)*diff(phi(2),t)*cos(phi(2))
phit=phi(2)
subs(diff(subs(B, phit, 'phit'),'phit'),'phit', phit)
I want to derive according to phi1(t), and the result is 0, but I expect (-1/2)*l1*m1*diff(phi0(t),t)*diff(phi1(t),t)*sin(phi1(t))
BUT, when I derive this B=(1/2)*l(1)*m(2)*diff(phi(1),t)*cos(phi(2)), it's all righ,
Any help would be appreciated
4 件のコメント
採用された回答
Walter Roberson
2013 年 3 月 9 日
The MuPAD Symbolic Toolbox cannot differentiate with respect to a function. (Maple cannot either.)
5 件のコメント
Walter Roberson
2013 年 3 月 10 日
In that case, you are differentiating with respect to a variable, not a function. Keep in mind that you are passing in 'phit' as a string, not phit by value (not quotation marks), so the symbol formed from 'phit' is going to be divorced from the phi(2) that appears in the expression.
The existence of the factor in your original expression of diff(phi(2),t) makes it especially questionable to differentiate a multiple of that factor by phi(2).
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!