Question about derivatives and function handles.

1 view (last 30 days)
I need to create a function which does the following:
as input, I should get something of the following (functions can be other an there can be more or less then 3 fuctions)
ϕ(a,b,c) = (a*(1/x^5) + b*cos(x) + c*log(x))^2 where x is a vector containing known elements.
Next I should compute the partial derivatie of ϕ(a,b,c) to a, b and c and organise the elements where the elements still containing a are in the first column, b in the second column, ... and the ones containing no variables are in the last column. That way i can create a linear system (A*x = b) which i can solve.
The problem is that I can create the derivative of functions but don't know how to create a function with functions as input which then can be derivated and later organise my elements in a matrix.

Answers (1)

Walter Roberson
Walter Roberson on 18 Mar 2013
How are you creating the partial derivatives? Are you using the symbolic toolbox? If you are, then instead of passing in function handles, pass in symbolic expressions representing the functions.
  1 Comment
Jonathan
Jonathan on 19 Mar 2013
Thanks for you answer! I'm almost there now. I indeed use symbolic toolbox to create my partial derivatives. My function can now take a symbolic function as input and computes the derivatives. My last question is, for example, lets say I have:
- (2*x*exp(c*x)*cos(x/b))/b^2 - (2*x*sin(x/b)*cos(x/b))/b^2 - (2*a*x*log(x)*cos(x/b))/b^2
Now I want to take all the terms containing 'a', then all the ones containing 'b' and the ones containing 'c'.
Would you know how this can ben done?
Thanks in advance

Sign in to comment.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!