Syntax Error Simulink fcn block

조회 수: 6 (최근 30일)
lokman alici
lokman alici 2020년 6월 6일
댓글: lokman alici 2020년 6월 7일
The expression: (-3*B*L*L*u(4))/J+(a*L*u(1))+(a*L*u(2))+(a*L*u(3)) in 'omnirobotcontrol/Subsystem/theta_2dot' has a syntax error.
WhY I am getting this error. I can't see the wrong :(
  댓글 수: 8
Ameer Hamza
Ameer Hamza 2020년 6월 7일
Can you show the code inside the MATLAB function block?
lokman alici
lokman alici 2020년 6월 7일
function x_2dot = fcn(u)
J = 0.01;
B = 0.1;
K = 0.01;
R = 1;
L = 0.5;
a=1;
m=1;
x_2dot=(-3*B*u(4))/(2*m)-((a*sin(u(5))*u(1))/m)-((a*sin((pi/3)-u(5))*u(2))/m)+((a*sin((pi/3)+u(5))*u(3))/m);
end

댓글을 달려면 로그인하십시오.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 6월 7일
Try this
function x_2dot = fcn(u)
x_2dot = 0; % initialize to tell simulink about its size
J = 0.01;
B = 0.1;
K = 0.01;
R = 1;
L = 0.5;
a=1;
m=1;
x_2dot=(-3*B*u(4))/(2*m)-((a*sin(u(5))*u(1))/m)-((a*sin((pi/3)-u(5))*u(2))/m)+((a*sin((pi/3)+u(5))*u(3))/m);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by