MATLAB How Can I Compute a Numerical Jacobian Matrix in MATLAB?

AI Thread Summary
To compute a numerical Jacobian matrix in MATLAB without the symbolic math toolbox, one can use the gradient function to obtain the gradient of a scalar field. By applying the gradient function twice on the resulting gradient matrix, the Hessian or Jacobian of the gradient can be derived. The proposed method involves creating a 3D matrix to store the gradient vectors and then calculating the gradient of this matrix. This approach is appropriate for analyzing a 100x100 image with pixel-based gradient vectors. The discussion focuses on numerical methods for Jacobian computation in MATLAB.
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
 

Similar threads

Replies
2
Views
3K
Replies
32
Views
4K
Replies
7
Views
2K
Replies
0
Views
5K
Replies
4
Views
2K
Replies
4
Views
2K
Back
Top