does anyone knows how to write vector components inside matlab function?
古いコメントを表示
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 件のコメント
per isakson
2016 年 1 月 20 日
Is there an error message?
Walter Roberson
2016 年 1 月 21 日
Does simulink consider x to be a vector or a 2D array?
Alexandre Masson Vicente
2016 年 1 月 21 日
編集済み: per isakson
2016 年 1 月 21 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Simulink Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!