Azzera filtri
Azzera filtri

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

13 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

madhan ravi
madhan ravi il 17 Dic 2018
Modificato: madhan ravi il 17 Dic 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 Commenti

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by