Numerical derivative in matlab

조회 수: 471 (최근 30일)
dont panic
dont panic 2013년 9월 26일
답변: Tamas Kis 2021년 4월 14일
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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 26일
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
dont panic
dont panic 2013년 9월 26일
thank you for your reply :) !

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Rohit Garud
Rohit Garud 2020년 8월 16일
편집: Rohit Garud 2020년 8월 16일
You can use the gradient() function in newer versions of matlab
dy_by_dt = gradient(y(:)) ./ gradient(t(:))
  댓글 수: 11
Daphne PARLIARI
Daphne PARLIARI 2021년 1월 6일
Oh I got confused... What would be the solution to that?
Walter Roberson
Walter Roberson 2021년 1월 6일
for k = 2:length(percent_change)
text(x(k),y(k),sprintf('%0.1f%%',percent_change(k)),...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom')
end

댓글을 달려면 로그인하십시오.


Tamas Kis
Tamas Kis 2021년 4월 14일
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.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by