How Can I Compute a Numerical Jacobian Matrix in MATLAB?

In summary, the conversation discusses how to compute the jacobian matrix numerically in Matlab without using the symbolic math toolbox. One solution suggested is to use the gradient function to calculate the gradient of a scalar field and then compute the gradient of the gradient to obtain the hessian or jacobian matrix. The correctness of this solution is also questioned.
  • #1
pamparana
128
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
  • #2
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
 

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

1. What is a numerical jacobian in Matlab?

A numerical jacobian in Matlab is a method for approximating the derivative of a function at a given point. It is useful for finding the gradient of a function when the analytical expression for the derivative is not known.

2. How do I use the numerical jacobian function in Matlab?

To use the numerical jacobian function in Matlab, you first need to define the function you want to find the derivative of. Then, you can use the "jacobian" function with the desired inputs to calculate the numerical jacobian at a specific point.

3. What is the purpose of using a numerical jacobian in Matlab?

The purpose of using a numerical jacobian in Matlab is to approximate the derivative of a function when the analytical expression is not available. This can be useful for optimization problems and solving systems of equations.

4. Can I use the numerical jacobian in Matlab for non-linear functions?

Yes, the numerical jacobian function in Matlab can be used for both linear and non-linear functions. However, the accuracy of the approximation may vary depending on the complexity of the function.

5. Are there any limitations to using the numerical jacobian in Matlab?

One limitation of using the numerical jacobian in Matlab is that it relies on the accuracy of the input function. If the function is not well-defined or has discontinuities, the numerical jacobian may not provide an accurate approximation.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
860
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • General Math
Replies
11
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Back
Top