How to take time derivatives of a function?

6 ビュー (過去 30 日間)
Christian Aranas
Christian Aranas 2018 年 7 月 25 日
コメント済み: Roger Bijlani 2020 年 8 月 27 日
My objective is to take the first and second time derivatives of my function for displacement 'x'. I have it modelling a function of displacement over angle with respect to time. Does MATLAB have a function that represents dx/dt? Here are the analytical solutions and my code for reference.
h = 60 ;
b =130 ;
r = 28 ;
w = 2*pi; % angular velocity
t =0:(1/36):1 ;
x = b*(r*sin(w*t))./(h-r*cos(w*t));

採用された回答

KSSV
KSSV 2018 年 7 月 25 日
dxdt = diff(x)./diff(t) ; % derivative of x w.r.t t
  3 件のコメント
KSSV
KSSV 2018 年 7 月 25 日
When we use diff the dimension of vector will be reduced by one. Two options to plot.
v = diff(x)./diff(t) ; % derivative of x w.r.t t
plot(v,t(1:end-1));
OR
v = gradient(x)./gradient(t) ; % derivative of x w.r.t t
plot(v,t);
Roger Bijlani
Roger Bijlani 2020 年 8 月 27 日
Thank you for this answer! All the examples online just show symbolic integration!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by