Can anyone help with this line 6 error
function dy = cartpend(y,m,M,L,g,d,u)
% dy = time derivative given y=state, m=mass of pendular arm, M = mass of
%cart,l=length of pendulum, g = gravity,d= damping term
%Right hand side function for inverted pendulum on cart
Sy = sin(y(3)); (Says error on this part; not enough input arguments)
Cy = cos(y(3));
D = m*L*L*(M+m*(1-Cy^2));
dy(1,1) = y(2);
dy(2,1) = (1/D)*(-m^2*L^2*g*Cy*Sy + m*L^2*(m*L*y(4)^2*Sy - d*y(2))) + m*L*L*(1/D)*u;
dy(3,1) = y(4);
dy(4,1) = (1/D)*((m+M)*m*g*L*Sy - m*L*Cy*(m*L*y(4)^2*Sy - d*y(2))) - m*L*Cy*(1/D)*u;
end

回答 (1 件)

KSSV
KSSV 2020 年 12 月 8 日

0 投票

Did you enter all your input variables? Don't run the function files using run button or F5 key. You need to define the input variables and then call the function.
y = define your variables ;
m = define your variables ;
M = define your variable ;
L = define your variables ;
g = define your variable ;
d = define your variables ;
u = define your variables ;
dy = cartpend(y,m,M,L,g,d,u) ;

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

2020 年 12 月 8 日

回答済み:

2020 年 12 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by