Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alan Weiss

Posts: 1,256
Registered: 11/27/08
Re: How to use lsqnonlin with the option "JacobPattern"
Posted: Oct 21, 2013 8:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 10/18/2013 2:55 PM, Fang wrote:
> Alan_Weiss <aweiss@mathworks.com> wrote in message
> <l3rtu6$638$1@newscl01ah.mathworks.com>...

>> 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?

>> >
>> > Thank you in advance.

>>
>> 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

>
> Thank you very much, Alan. So JacobPattern is to pass the locations of
> the nonzero derivatives, but how to pass the nonzero elements
> (functions_handle) in the Jacobian matrix to lsqnonlin?


If you can calculate the Jacobian, don't use the JacobPattern option.
Set the 'Jacobian' option to 'on' and pass the Jacobian in the function
definition, as described here:
http://www.mathworks.com/help/optim/ug/writing-objective-functions.html#brkjtxo

Alan Weiss
MATLAB mathematical toolbox documentation



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.