Numerical derivative in matlab

462 vues (au cours des 30 derniers jours)
dont panic
dont panic le 26 Sep 2013
Hello,
I'm using Matlab 2012 and would need the numerical derivative of a function. What is the Malab command for that ?
Thank you in advance
  1 commentaire
Leah
Leah le 26 Sep 2013
I like your user name

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 26 Sep 2013
If you have a series of data
t=[0 1 2 3 4 5] % Vector time
y=[1 2 4 8 12 13] % Your signal
% The derivative can be approximated :
diff(y)./diff(t)
%You can also use symbolic derivative
syms t y
y=cos(t)
dy=diff(y)
  1 commentaire
dont panic
dont panic le 26 Sep 2013
thank you for your reply :) !

Connectez-vous pour commenter.

Plus de réponses (2)

Rohit Garud
Rohit Garud le 16 Août 2020
Modifié(e) : Rohit Garud le 16 Août 2020
You can use the gradient() function in newer versions of matlab
dy_by_dt = gradient(y(:)) ./ gradient(t(:))
  11 commentaires
Daphne PARLIARI
Daphne PARLIARI le 6 Jan 2021
Oh I got confused... What would be the solution to that?
Walter Roberson
Walter Roberson le 6 Jan 2021
for k = 2:length(percent_change)
text(x(k),y(k),sprintf('%0.1f%%',percent_change(k)),...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom')
end

Connectez-vous pour commenter.


Tamas Kis
Tamas Kis le 14 Avr 2021
Function that can differentiate a set of points given as vectors (such as how you would use cumtrapz to integrate), or differentiate a function defined using a function handle. It can differentiate at any specified point(s) or over an entire domain. Also is of slightly higher accuracy than using diff(y)./diff(t) because it uses central approximation at the interior nodes.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by