Symbolic and Jacobian Matrix
23 views (last 30 days)
Show older comments
Hello,
I am currently using Matlab and the symbolic toolbox to calculate the Jacobian Matrix of different Matrix equations/state space representations.
One equation is
A=(1/m).*T*N*u
which in detail looks like this:
Now I'm calculating the Jacobian of A with respect to u by using jacobian(A,u), which is just
(1/m).*T*N
Now I have 3 questions:
- Currently I'm writing syms phi theta psi u1 u2 u3 u4 n11 n12 n13 n14 n21 ... Is there a more elegant solution to of telling Matlab that a Matrix consists of/is a symbolic variable?
- I tried to verify the result by calculating jacobian(A,u) - (1/m).*T*N, which for some reason Matlab does not simplify. Instead it outputs for the first element for example [(n11 + n21*psi - n31*theta)/m - n11/m - (n21*psi)/m + (n31*theta)/m], which just equals to 0. Why doesnt it show 0 as result?
- The way I'm currently doing it (see 1.), the output I get is mutiplied out. Is there a way to reverse that, so that I know that my result equals (1/m).*T*N ?
I hope someone can help me with these issues.
0 Comments
Answers (1)
J Chen
on 13 May 2020
Try the following. They gave what you want in Matlab R2019b.
syms m phi theta psi u1 u2 u3 u4
N = sym('n%d%d', [3 4])
T = [1 psi -theta;-psi 1 phi;theta -phi 1]
U = [u1; u2; u3; u4]
A = 1/m*T*N*U
jacobian(A,U)
fprintf('\nVerification\n')
difference = jacobian(A,U) - 1/m*T*N
See Also
Categories
Find more on Number Theory 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!