VOOZH about

URL: https://www.geeksforgeeks.org/matlab/differential-or-derivatives-in-matlab/

⇱ Differential or Derivatives in MATLAB - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Differential or Derivatives in MATLAB

Last Updated : 23 Aug, 2021

Differentiation of a function y = f(x) tells us how the value of y changes with respect to change in x. It can also be termed as the slope of a function.

Derivative of a function f(x) wrt to x is represented as 

MATLAB allows users to calculate the derivative of a function using diff() method. Different syntax of diff() method are:

  • f' = diff(f)
  • f' = diff(f, a)
  • f' = diff(f, b, 2)

f' = diff(f)

It returns the derivative of function f(x) wrt variable x.

Example 1:

Output :

👁 Image

Example 2: Evaluating the derivative of a function at a specified value using subs(y,x,k).

  • subs(y,x,k), it gives the value of function y at x = k.

Output :

👁 Image

f' = diff(f, a)

  • It returns the derivative of function f with respect to variable a.

Output :

👁 Image

f' = diff(f, b, 2)

It returns the double derivative of function f with respect to variable b.

Example 1:

Output :

👁 Image

In the same way, you can also calculate the k-order derivative of function f using diff(f,x,k).

Example 2: 

Calculating the partial derivative } using Jacobian matrix and determinant.

Output :


 

👁 Image


 

Comment