Path: news.mathworks.com!not-for-mail
From: "Toan Cao" <toancv3010@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Optimization with function: lsqnonlin
Date: Thu, 28 Mar 2013 17:29:07 +0000 (UTC)
Organization: university of Ulsan
Lines: 41
Message-ID: <kj1ul3$ho4$1@newscl01ah.mathworks.com>
References: <kivpf1$st9$1@newscl01ah.mathworks.com> <kj1dhf$hh5$2@newscl01ah.mathworks.com>
Reply-To: "Toan Cao" <toancv3010@gmail.com>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1364491747 18180 172.30.248.46 (28 Mar 2013 17:29:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 28 Mar 2013 17:29:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2244433
Xref: news.mathworks.com comp.soft-sys.matlab:792210

Alan_Weiss <aweiss@mathworks.com> wrote in message <kj1dhf$hh5$2@newscl01ah.mathworks.com>...
> On 3/27/2013 5:48 PM, Toan Cao wrote:
> > Hi everyone,
> > I know there are many people who have uses function "lsqnonlin" for 
> > optimization.  Currently, I am encountering a problem relating 
> > calculation of Jacobian matrix for this function.
> > My problem is described as follows:
> >
> > I have a vector-value function F consists of n=1000 scale-value 
> > functions. Total variables for F is  about m=700.
> > 1) I define a mx1 symbolic array of symbolic variables: X=[X1; X2; 
> > ...; X700].
> > 2) Then, i compute symbolic gradient  : grad_F = jacobian(F,X).
> > 3) After step 2, i have Jacobian matrix nxm of F  in Symbolic 
> > Expression, for example
> > grad_F = [2*X1 +5*X7 - 35*X550;               4*X12 + 56*X45;
> >              .....
> >               67*X1 - 45*X15*X17]
> > Now, if i want to obtain Jacobian matrix of F with a real variable y 
> > =[1; 2;...;700], how can i do ?
> > Of course, we can use "for loop" by running row by row of grad_F and 
> > replace a symbolic variable Xi by a respective real variable y(i) at 
> > each position in this matrix. Uhmm, It takes so long time to 
> > accomplish just for one time.
> >
> > If you have any solution, please help me.
> > Thanks in advance,
> > Toan
> 
> Take a look at some documentation on using symbolic variables with 
> Optimization Toolbox:
> http://www.mathworks.com/help/optim/examples/using-symbolic-mathematics-with-optimization-toolbox-solvers.html
> http://www.mathworks.com/help/optim/ug/symbolic-math-toolbox-calculates-gradients-and-hessians.html
> 
> Alan Weiss
> MATLAB mathematical toolbox documentation

Hi Alan Weiss. 
Thanks for your links, they are very useful.

Toan