Numerically derive a continous, non-symbolic function

조회 수: 5 (최근 30일)
fi
fi 2019년 11월 26일
댓글: darova 2019년 11월 27일
I have a function defined via
function y = f(x)
% ...
end
. I now want to numerically calculate the value of it's derivative at a given point. As in, what should be in the following function's body?
function y = derivative_of_f(x)
% Calculate derivative of f at position x here
end
Is there any way to do this, without having to implement numerical differentiation myself?

채택된 답변

darova
darova 2019년 11월 26일
편집: darova 2019년 11월 27일
Derivative is (if you have numerical data)
dy = (y(i)-y(i-1)) / (t(i)-t(i-1));
Maybe diff (if you have a function) ?
syms x
diff(f(x))
  댓글 수: 8
fi
fi 2019년 11월 27일
Well, the answer is currently in your comment and there is no accept button for that :(
Could you maybe edit you original answer?
darova
darova 2019년 11월 27일
yes please

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

추가 답변 (0개)

카테고리

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