Not enough Input Arguments
显示 更早的评论
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
2020-12-8
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 Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!