how to calculate the partial derivatives for a given function of two variable ?

58 views (last 30 days)
NoorKh
NoorKh on 13 Dec 2019
Answered: Dyuman Joshi on 14 Dec 2019
How can I write code to calculate the partial derivatives a given function of two variable ?

Answers (1)

Dyuman Joshi
Dyuman Joshi on 14 Dec 2019
Hello, You can use diff function operator to obtain partial derivatives as follows:
1- Define a function using syms function. (symbolic variable)
syms x y;
f = @(x,y) x^2 + y^2 + x*y;
2-use diff with respect to the variable you want to differentiate.
z(x,y) = diff(f,x)
%which will give
z(x,y) = 2*x+y;
You can also find the value of parial differential at a point by calling z at a given point.

Community Treasure Hunt

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

Start Hunting!

Translated by