Unable to calculate the second derivative of a function

1 vue (au cours des 30 derniers jours)
Ravi Joshi
Ravi Joshi le 18 Avr 2015
I want to calculate the second derivative of a function. Below are the steps I am following-
syms a b;
th = sym('th(t)'); %th is a time dependent variable
y = diff(a^2*cos(th)+(b/12)*sin(th));
thd = diff(th); %derivative of th wrt time
ybythd = diff(y,thd); %derivative of y wrt thd
p = diff(ybythd); %derivative of ybythd wrt time
It calculates the following value of p
p = diff(diff((b*cos(th(t))*diff(th(t), t))/12 - a^2*sin(th(t))*diff(th(t), t), t), diff(th(t), t))
I do not see any term of d2th/dt2 in the above result. What is missing?
  1 commentaire
Andriy Kavetsky
Andriy Kavetsky le 6 Oct 2016
y = diff(a^2*cos(th)+(b/12)*sin(th),th,2) %second derrivative ////////////////////////////////////////// y = diff(a^2*cos(a)+(b/12)*sin(a),a,2) %second derrivative from a and its result
y =
2*cos(a) - 4*a*sin(a) - (b*sin(a))/12 - a^2*cos(a)

Connectez-vous pour commenter.

Réponses (1)

Marc Jakobi
Marc Jakobi le 6 Oct 2016
change
th = sym('th(t)'); %th is a time dependent variable
to
th = sym('th'); %th is a time dependent variable

Community Treasure Hunt

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

Start Hunting!

Translated by