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

210 Ansichten (letzte 30 Tage)
How can I write code to calculate the partial derivatives a given function of two variable ?

Antworten (1)

Dyuman Joshi
Dyuman Joshi am 14 Dez. 2019
Bearbeitet: Dyuman Joshi am 12 Aug. 2023
Hello, You can use diff function operator to obtain partial derivatives as follows:
1- Define the function using symbolic variables
%Random function for example
syms x y;
f(x,y) = x^2 + y^2 + x*y;
2-use diff with respect to the variable you want to differentiate.
fx = diff(f,x)
fx(x, y) = 
fy = diff(f,y)
fy(x, y) = 
You can also find the value of parial derivatives by substituting the value -
fx(1,0)
ans = 
2

Community Treasure Hunt

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

Start Hunting!

Translated by