Creating and differentiating symbolic functions with vector inputs of different dimensions

Hi,
I would like to do the following:
1) Define a callable symbolic function F of variables X and Y, where X and Y are vectors of different dimensions.
2) Then, take the Jacobian of F with respect to either X or Y, and not the individual elements of X and Y.
Is there a way to do this?
Thanks! Stephanie

 Accepted Answer

I solved the problem. Here's the solution:
  1. Reshape and combine X and Y into one row vector.
  2. Call symfun with the row vector as the second input to create the function f.
Once we have the function f, we can take its jacobian with the original vectors X and Y to produce another symbolic function.
When calling f, to take its Jacobian for instance:
  1. Put all of the inputs into a row vector.
  2. use num2cell to convert the row vector into a cell array, called "symbolic_input"
  3. Call f: f(symbolic_input{:})

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!