does anyone knows how to write vector components inside matlab function?
13 views (last 30 days)
Show older comments
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.
3 Comments
Answers (0)
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!