How to use syms inside a function that is called in simulink?
Afficher commentaires plus anciens
I have an Extended Kalman Filter in which I have written Matlab functions for jacobians.
I have used syms from symbolic toolbox in order to compute the jacobians. However I get the error message "Function 'syms' not supported for code generation." when I run the Simulink Function.
How do I avoid this error and compute the jacobians ?
The following is my jacobian function which I use in the EKF block.
function Jss = stateTransitionJacobian(X,U)
syms x [3 1];
syms y [3 1];
syms z [4 1];
syms a [3 1];
syms b [3 1];
ge=[0; 0; 9.81];
deltat=0.01;
p=(X(1:3));
v=(X(4:6));
q=(X(7:10));
fm=(U(1:3));
omegam=(U(4:6));
Qplus=[z1 -z2 -z3 -z4; z2 z1 -z4 z3; z3 z4 z1 -z2; z4 -z3 z2 z1];
Qminus=[z1 -z2 -z3 -z4; z2 z1 z4 -z3; z3 -z4 z1 z2; z4 z3 -z2 z1];
I34=[0 1 0 0; 0 0 1 0; 0 0 0 1];
Rq=I34*Qplus*transpose(Qminus)*transpose(I34);
x1=Rq*y;
y1=a-transpose(Rq)*ge;
z1=0.5*Qplus*([b; 0]);
% Xdot=[p1; v1; q1];
Js=jacobian([x; y; z]+[x1; y1; z1]*deltat,[x; y; z]);
Jss=subs(Js,[x; y; z; a; b],[p; v; q; fm; omegam]);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!