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!