Can you help me please !
1 次查看(过去 30 天)
显示 更早的评论
I run code Matlab:
function yp=khidonghoc(t,y)
m = 10;
cd = 0.2;
g = 9.81;
w = m*g;
tspan=[0 5];
y0=[0;100;0;10];
yp = zeros(4,1);
yp(1)= y(2);
yp(2) = ((-cd/m)*y(2)*(y(2)^2+y(4)^2)^(0.5));
yp(3) = y(4);
yp(4) = ((-w/m)-(cd/m)*y(4)*(y(2)^2+y(4)^2)^(0.5));
[t,y]=ode45('khidonghoc',tspan,y0);
plot(t,y(:,1),y(:,3))
hold on;grid on;
xlabel('X-Displacement')
ylabel('Y-Displacement')
title('X vs Y Displacement')
end
Matlab error: "Not enough input arguments.
Error in khidonghoc (line 9)
yp(1)= y(2);"
Thanks you very much.
2 个评论
Adam
2019-9-3
Pass in some arguments! How did you call the function? It expects two input arguments so if you don't pass them in it will give you that error.
采纳的回答
Torsten
2019-9-3
function main
tspan=[0 5];
y0=[0;100;0;10];
[t,y]=ode45(@khidonghoc,tspan,y0);
plot(t,y(:,1),t,y(:,3))
hold on;grid on;
xlabel('X-Displacement')
ylabel('Y-Displacement')
title('X vs Y Displacement')
end
function yp=khidonghoc(t,y)
m = 10;
cd = 0.2;
g = 9.81;
w = m*g;
yp = zeros(4,1);
yp(1)= y(2);
yp(2) = ((-cd/m)*y(2)*(y(2)^2+y(4)^2)^(0.5));
yp(3) = y(4);
yp(4) = ((-w/m)-(cd/m)*y(4)*(y(2)^2+y(4)^2)^(0.5));
end
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!