ode45 Not enough input agruments
1 view (last 30 days)
Show older comments
Hey guys,
Ive been having a problem with my code and cant seem to fix it. Every time I run my f_count.m function i receive the error message:
>> f_count(Disp_Error,10,1,0.0001)
Not enough input arguments.
Error in Disp_Error (line 8)
[t,y]=ode45(@f_freefall,[t0, t_release],Disp0,options);"
The code is:
function [result,count] = f_count(DE,t_release,dx,tol)
count=0;
while norm(dx)>tol
t0=0;
tf=50;
Disp0=[0;1500;0;0];
Dispf=[650,-6.50];
tspan=[t0 t_release];
options=odeset('RelTol',0.0001,'AbsTol', 0.0001);
[~,y]=ode45(@f_freefall,tspan, Disp0,options);
size2=y(end,:);
tspan2=[t_release tf];
[~,y]=ode45(@f_parachute,tspan2,size2,options);
y=real(y);
size3=size(y,1);
for i=1:size3;
if y(i,2)>=Dispf(2);
size4(i,:)=y(1,:);
end
end
t0=t_release;
f=@Disp_Error;
f0=f(t0);
t0=t_release+dx;
f=@Disp_Error;
f1=f(t0);
new_dt=(f1-f0)/dx(1);
size5=new_dt'+eps;
t_release=t_release+dx;
size5=size5(:);
dx=(-size5\f0 - dx);
result=t_release;
count=count+1;
end
fprintf('Count=%d\n,Result=%d\n',count,t_release)
end
And:
function Displacement = f_freefall(t,y)
m=90;
gravity=9.81;
c1=0.27;
sx=y(1);
sy=y(2);
ux=y(3);
uy=y(4);
u=10*((sy+sx*0.01)/(1500+sx*0.01))^0.14;
ut=sqrt(((ux-u)^2)+uy^2);
ax=(-c1*(ux-u)*ut)/m;
ay=(-c1*(uy*ut))/m - gravity;
Displacement=[ux;uy;ax;ay];
end
Any help would be greatly appreciated!!!
0 Comments
Answers (1)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!