Calculating jacobian while using symbolic toolbox
Show older comments
Hello! I can't seem to find the answer to my problem so I figured that I'd ask it myself.
I am trying to calculate the jacobian based on symbolic variables as follows:
syms x(t) y(t) z(t) theta(t) phi(t) L
q = [x, y, z, theta, phi].';
dq = diff(q,t);
p1 = [x, y, z].';
dp1 = diff(p1, t);
p2 = [x + L*cos(theta),
y + L*cos(phi),
z + L*sin(theta) + L*sin(phi)];
dp2 = jacobian(p2, q)*dq;
I want to use it to module a system using Lagrange modelling.
The error message comes as follow:
Error using sym/jacobian (line 44)
Second argument must be a vector of variables.
Error in untitled (line 15)
dp2 = jacobian(p2, q)*dq;
Thanks in advance, Jakob
5 Comments
Bjorn Gustavsson
on 20 Sep 2019
My (admittedly old) version of jacobian doesn't like the time-variations in the variables x, y, z, theta, phi. Perhaps you can work your way around it by calculating the jacobian for variables not depending on time and then substitute the time-varying ones after that?
Walter Roberson
on 20 Sep 2019
You cannot (at all easily) differentiate with respect to a function, only with respect to a variable.
Jakob Vinkås
on 20 Sep 2019
Bjorn Gustavsson
on 20 Sep 2019
Also: are you sure about the expression for p2? It seems suspicious to me.
Walter Roberson
on 20 Sep 2019
In particular if you are working with polar coordinates then you would normally multiply two trig components rather than add them.
Answers (0)
Categories
Find more on Mathematics 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!