I want to calculate the differentiation of the function of two variables. For instance:
ax^2 + by^2 + cxy
So, I am doing this:
a = 1
b = 1
c = 1
syms x y f
f = a*x^2 + b*y^2 + c*x*y
df = matlabFunction(diff(f,'x'))
which returns:
df =
@(x,y)x.*2.0+y
And this is normal. But if c is zero, it returns this:
df =
@(x)x.*2.0
and I can't call it with two arguments anymore, but I need to pass two arguments, even if y is no longer in the definition, since c is not always zero. How can i fix this?
source
share