How Can I Compute a Numerical Jacobian Matrix in MATLAB?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 7K views
pamparana
Messages
123
Reaction score
0
Hello everyone,

Does anyone know how I can compute the jacobian matrix numerically in matlab?

So, I have the following. A 100x100 image and at each pixel, I have a 2 element gradient vector. What I would like to do is compute the jacobian matrix (wrt to the spatial location), at each pixel position.

Does anyone know how I can do that? I do not have the symbolic math toolbox, so I cannot use the built-in jacobian function :(

Thanks,

Luc
 
Physics news on Phys.org
So, I did the following, which I hope is correct:

[FX, FY] = gradient(fun); % Gradient of the scalar field. Jacobian of scalar field is the gradient
T = cat(3, FX, FY);
[TTX, TTY]=gradient(T); % Compute gradient of the gradient
TT=cat(3, TTX, TTY); % This should be the hessian or jacobian of the gradient

Does this seem correct?

Thanks,

Luc