Symbolic and Jacobian Matrix
23 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
J Chen
2020-5-13
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!