Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to evaluate the Jacobian in Matlab?

Tags:

matlab

I have this code:

syms x y z
f =[x^2+y^2+z^2-100 ,x*y*z-1 ,x-y-sin(z)];
v = [x, y, z];
fp = jacobian(f,v)

This gives:

fp =
[ 2*x, 2*y,     2*z]
[ y*z, x*z,     x*y]
[   1,  -1, -cos(z)]

Now I want to evaluate this at, say, x=y=z=1. But

fp([1,1,1])

gives me

[ 2*x, 2*x, 2*x]

Is there a way to do this?

like image 252
ario Avatar asked Dec 20 '22 23:12

ario


1 Answers

You can use the subs function:

subs(fp, [x y z], [1 1 1])
like image 92
dumbmatter Avatar answered Jan 04 '23 19:01

dumbmatter