Thread Subject: convert symbolic jacobian into matrix

Subject: convert symbolic jacobian into matrix

From: nico cruz

Date: 8 Feb, 2010 15:17:04

Message: 1 of 3

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?

I hope someone can help me

Subject: convert symbolic jacobian into matrix

From: Steven Lord

Date: 8 Feb, 2010 16:15:44

Message: 2 of 3


"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

Subject: convert symbolic jacobian into matrix

From: nico cruz

Date: 9 Feb, 2010 10:57:02

Message: 3 of 3

It worked fine
Thanx!

"Steven Lord" <slord@mathworks.com> wrote in message <hkpdbc$gnv$1@fred.mathworks.com>...
>
> "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
>

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com