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!