Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: convert symbolic jacobian into matrix
Date: Mon, 8 Feb 2010 11:15:44 -0500
Organization: The MathWorks, Inc.
Lines: 38
Message-ID: <hkpdbc$gnv$1@fred.mathworks.com>
References: <hkp9tg$d0i$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1265645740 17151 172.31.44.65 (8 Feb 2010 16:15:40 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 8 Feb 2010 16:15:40 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:605426


"nico cruz" <m.nicolas.cruz@mailbox.tu-berlin.de> wrote in message 
news:hkp9tg$d0i$1@fred.mathworks.com...
> Hi,
>
> I have been trying to convert a jacobian generated with the symbolic 
> toolbox into a matrix. I used to do it with eval, but the profile viewer 
> showed that this function needs 95% of the calculation time.
>
> my problem looks like this (allthough in my case Jac is a 32x32 matrix) :
>>> syms('V', 'r', 'A', 'X')
>>> Jac = [V*A r; X*r A]
>
> Jac =
>
> [ A*V, r]
> [ X*r, A]
>
> if I use vectorize to get a string it gets even worse:
> matrix([[A.*V,r],[X.*r,A]])
>
> how can I convert Jac to:
>
> Jac = [ A.*V  r
>           X.*r  A]
> so it is posible for me to use it without having to use the command eval 
> every time?

Use the matlabFunction function.

http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/matlabfunction.html

-- 
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ