does anyone knows how to write vector components inside matlab function?
13 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!