Problem using subs function for multiple variables on 2023b
이전 댓글 표시
Hi, I have the following code:
syms ml1 ml2 a1 a2 q1 q2 q1p q2p q1pp q2pp l1 l2 g real
syms theta1(t) theta2(t)
type_sym= [q1 q1p q1pp q2 q2p q2pp];
type_symfun= [...
theta1(t) diff(theta1(t),t) diff(theta1(t),t,t) ...
theta2(t) diff(theta2,t) diff(theta2,t,2)];
X0p =[(a1^2*cos(theta1(t))^2 + a1^2*sin(theta1(t))^2)*diff(theta1(t), t, t) ; 0] ;
X0p=subs(X0p,type_symfun,type_sym);
disp(X0p)
And I obtain:
[0 ;0]
which is wrong. I its happening on Matlab 2023b version. However, on previous versions, I didn’t get this problem. Any idea?
댓글 수: 2
Dyuman Joshi
2023년 11월 1일
"which is wrong."
It is correct.
When you substitute q1 for theta1(t), the expression changes to
a1^2*diff(q1, t, 2)
And as you q1 is not a function of t, it is treated as a constant, thus it's 2nd derivative w.r.t t is zero.
Jose
2023년 11월 1일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Code Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

