Filter löschen
Filter löschen

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

13 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

madhan ravi
madhan ravi am 17 Dez. 2018
Bearbeitet: madhan ravi am 17 Dez. 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 Kommentare

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by