does anyone knows how to write vector components inside matlab function?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I tried to create a simulink block with embedded code through "matlab function":
function xdot = fcn(m,J,u,x)
%#codegen
R = [cos(x(8))*cos(x(9)) cos(x(8))*sin(x(9)) -sin(x(8));
-cos(x(7))*sin(x(9))+sin(x(7))*sin(x(8))*cos(x(9)) cos(x(7))*cos(x(9))+sin(x(7))*sin(x(8))*sin(x(9)) sin(x(7))*cos(x(8));
sin(x(7))*sin(x(9))+cos(x(7))*sin(x(8))*cos(x(9)) -sin(x(7))*cos(x(9))+cos(x(7))*sin(x(8))*sin(x(9)) cos(x(7))*cos(x(8))];
%
M = [1 sin(x(7))*tan(x(8)) cos(x(7))*tan(x(8));
0 cos(x(7)) -sin(x(7)) ;
0 sin(x(7))*sec(x(8)) cos(x(7))*sec(x(8))];
%
Wskew = [ 0 -x(12) x(11);
x(12) 0 -x(10);
-x(11) x(10) 0 ];
%
Vb = [x(4);
x(5);
x(6)];
%
W = [x(10);
x(11);
x(12)];
%
xdot=[R*Vb;
F-Wskew*Vb;
M*W;
J\(N-Wskew*J*W];
But matlab does not interpret the entries of vector "x" to form the matrices "W", "Vb", "R" and "Wskew".
DOES ANYONE HAVE ANY IDEA THAT I CAN TRY ON THIS PROBLEM?
Thanks.
Réponses (0)
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!