How to substitute a value for the time derivative of a function

22 views (last 30 days)
Hellow
I have a dispalcemet function of time defined as:
syms d(t)
>> a = d^2+sin(d)
The first derivative is the velocity:
>> v = diff(a)
v(t) =
cos(d(t))*diff(d(t), t) + 2*d(t)*diff(d(t), t)
the parameter diff(d(t), t) means the velocity value but How I can substitute a value for it using subs or any other function?
thank you

Accepted Answer

madhan ravi
madhan ravi on 17 Dec 2018
Edited: madhan ravi on 17 Dec 2018
use subs() like below:
syms d(t)
a = d^2+sin(d);
v = diff(a);
after=subs(v,diff(d),2) % here diff(d) is replace number 2
Gives:
after(t) =
2*cos(d(t)) + 4*d(t)
or use ode45() -> diff(d,2)==>acceleration the right hand side is as it is so we treat them now as second order ode which is then further reduced to first order odes.
[t,x]=ode45(@myod2,[0 2],[0;1]);
figure(1)
plot(t,x(:,1),'-ok')
figure(2)
plot(t,x(:,2),'-or')
function dxdt = myod2(t,Y)
dxdt=[Y(2);
sin(Y(1)) + Y(1)^2];
end
  4 Comments

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!