Jacobian Matix vector of variables?
13 views (last 30 days)
Show older comments
Hello, im want to get a jacobian from this code
syms x(t) y(t) z(t);
syms u(t) v(t) w(t);
syms p(t) q(t) r(t);
syms phi(t) theta(t) psi(t);
x_p=w(t)*(sin(phi(t))*sin(psi(t)) + cos(phi(t))*cos(psi(t))*sin(theta(t))) - v(t)*(cos(phi(t))*sin(psi(t)) - cos(psi(t))*sin(phi(t))*sin(theta(t))) + cos(psi(t))*cos(theta(t))*u(t);
y_p=v(t)*(cos(phi(t))*cos(psi(t)) + sin(phi(t))*sin(psi(t))*sin(theta(t))) - w(t)*(cos(psi(t))*sin(phi(t)) - cos(phi(t))*sin(psi(t))*sin(theta(t))) + cos(theta(t))*sin(psi(t))*u(t) ;
z_p=cos(phi(t))*cos(theta(t))*w(t) - sin(theta(t))*u(t) + cos(theta(t))*sin(phi(t))*v(t);
V=[x_p,y_p,z_p];
a=[x y z];
AP=jacobian(V,a)
That my error massage
Second argument must be a vector of variables.
Can someone pls explain to me,whats causing the problem?
0 Comments
Answers (1)
Stephan
on 20 Sep 2019
Edited: Stephan
on 20 Sep 2019
You have to distinguish between a symbolic variable
syms x
and a symbolic function
syms y(t)
This is why this works:
syms rho phi x y z
V = [3*phi*x^2+y; 2*rho/x*y; -x; 3*y]
a=[x y]
AP=jacobian(V,a)
V =
3*phi*x^2 + y
(2*rho*y)/x
-x
3*y
a =
[ x, y]
AP =
[ 6*phi*x, 1]
[ -(2*rho*y)/x^2, (2*rho)/x]
[ -1, 0]
[ 0, 3]
and your code does not. The second Input argument to jacobian have to be symbolic variables, not symbolic functions.
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!