I have a function where x and y are both vectors of an arbitrary length. The function d is a small part which appears many times in a larger function and I'd like to be able to have the derivatives of d show up as as opposed to the behavior that occurs if I fully define . However, if I try to do this with something like: syms d(x,y) real
syms x y real [1 4]
I'll end up with vectors:
x = [x1, x2, x3, x4]
y = [y1, y2, y3, y4]
Which means that if I take the Jacobian of this function I get:
jacobian(d,x) = [0,0,0,0]
As opposed to something like:
jacobian(d,x) = [diff(d,x1), diff(d,x2), ...
Which is my desired behavior.
Additionally, if I use syntax like:
syms x [1 4]
syms d(x) [1 4] matrix keepargs
jacobian(d,x)
I get the error:
Incorrect number or types of inputs or outputs for function 'jacobian'.
And if I use the syntax:
syms x [1 4] matrix
syms d(x) [1 4] matrix keepargs
diff(d,x)
I get the output:
Calling Jacobian gives the same error as before and attempting to differentiate w/r.t. any of the variables within symmatrix x throws an error saying it isn't a recognized variable.
Does anyone know how to get that behavior? In this case would I need to explicitly define something like ? I'm working on r2023a right now if that helps.