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

Contact us at files@mathworks.com