Symbolic Substitution(subs) is not working , why?

조회 수: 7 (최근 30일)
Mirroyal Ismayilov
Mirroyal Ismayilov 2018년 7월 27일
댓글: Walter Roberson 2018년 8월 1일
T(t) =
(25*diff(r1(t), t)^2)/12 + (25*diff(r2(t), t)^2)/8 + (25*cos(r1(t))^2*diff(r1(t), t)^2)/4 + (25*sin(r1(t))^2*diff(r1(t), t)^2)/4 + (3*(5*cos(r1(t))*diff(r1(t), t) + (5*cos(r2(t))*diff(r2(t), t))/2)^2)/2 + (3*(5*sin(r1(t))*diff(r1(t), t) + (5*sin(r2(t))*diff(r2(t), t))/2)^2)/2
T is gained from somewhere which is long story but it works perfectly fine. My code is following:
syms T r1(t) k1
subs(T,r1,k1);
P1=diff(T,k1);
Because I can't differentiate in terms of symbolic function, I wanted to replace r1 with k1, but it doesn't replace and subs function gives back these:
ans(t) =
(25*diff(r2(t), t)^2)/8 + (75*cos(r2(t))^2*diff(r2(t), t)^2)/8 + (75*sin(r2(t))^2*diff(r2(t), t)^2)/8
Somehow r1(t)'s are disappeared but couldn't been replaced with k1. Because there is not k1 in substituted function,differentiation(diff) gives back just 0(zero) which is normal.
Can someone explain me the situation please?

채택된 답변

Walter Roberson
Walter Roberson 2018년 7월 27일
No, the substitution is working. But you have diff(r1(t),t) and when you replace r1(t) with k1, that becomes diff(k1, t) and since k1 is independent of t, the diff() becomes 0.
  댓글 수: 2
Mirroyal Ismayilov
Mirroyal Ismayilov 2018년 7월 27일
편집: Mirroyal Ismayilov 2018년 7월 31일
Mr Walter, Although subs is working, still I can't get answer as wanted since whenever I substitute symbolic function with symbolic variables, it automatically makes things zero. I had to use subs because I don't still understand why it is not possible to derive the symbolic function in terms of symbolic function. Do you have any suggestion?
Walter Roberson
Walter Roberson 2018년 8월 1일
Perhaps you want to use functionalDerivative()
But what I recommend is that you look at the first example in odeFunction() to see how to convert equations with derivatives into systems of equations.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by