Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to use lsqnonlin with the option "JacobPattern"
Replies: 3   Last Post: Oct 21, 2013 8:27 AM

 Messages: [ Previous | Next ]
 Alan Weiss Posts: 1,430 Registered: 11/27/08
Re: How to use lsqnonlin with the option "JacobPattern"
Posted: Oct 18, 2013 2:16 PM

On 10/18/2013 12:39 PM, Fang wrote:
> I have a large-size problem, and the Jacobian matrix is sparse. In the
> document, there is a "JacobPattern" option, but I cannot find any
> example about how to use it. Anyone can help?
>
> I tried to create a Jacobian matrix using sparse() function, but the
> problem is sparse() can not be used by "function_handle". I guess
> "JacobPattern" can solve this problem, but how?
>

You are quite right, this is not documented properly. I will have to see
to that.

In any case, here's how to do it. For lsqnonlin you have a vector
function F(x) of a vector x. The JacobPattern matrix J is supposed to be
a sparse matrix, with J(i,j) = 1 whenever the ith component of F can
have a nonzero derivative with respect to x(j).

Pass the matrix J as the JacobPattern option:
options = optimset('JacobPattern',J,'Algorithm','trust-region-reflective');

Alan Weiss
MATLAB mathematical toolbox documentation

Date Subject Author
10/18/13 Fang
10/18/13 Alan Weiss
10/18/13 Fang
10/21/13 Alan Weiss