I'm working on a code in a group for a class. One of the biggest obstacles is figuring out a code to do partial derivatives. Octave is similar to Matlab syntax wise but it does not do symbols "sym". I'm kinda stuck as to how to go about doing a partial derivative in the program. It has to be done in Octave, it cannot be done in Matlab.
Basically just parroting what @rayryeng has said in his comment, but a small self-contained example to find the partial derivative of y(x, z) = x^2 + z^2
with respect to x
:
pkg load symbolic
syms x z
y = x^2 + z^2
diff(y, x)
Gives the result:
ans = (sym) 2*x
Which is the correct partial derivative of y
with respect to x
. Note that to get this to work you will have to install the symbolic package. I found that I also needed to have the python package SymPy
installed. There are some helpful instructions here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With