ode45 Not enough input agruments

1 view (last 30 days)
Rick J
Rick J on 30 Oct 2016
Commented: Walter Roberson on 30 Oct 2016
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!!!

Answers (1)

Walter Roberson
Walter Roberson on 30 Oct 2016
Probably you need
f_count(@Disp_Error,10,1,0.0001)
  2 Comments
Rick J
Rick J on 30 Oct 2016
Thanks for quick response! Ive been trying that as well, but it seems to go into an infinite loop, and then output:
"Warning: Failure at t=-9.022404e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.842171e-14) at time t.
> In ode45 (line 308)
In Disp_Error (line 8)
In f_count (line 27)
Subscript indices must either be real positive integers or logicals.
Error in Disp_Error (line 20)
DispErr=Dispf-(size2(end,1:2)');
Error in f_count (line 27)
f1=f(t0);
Walter Roberson
Walter Roberson on 30 Oct 2016
We will need to see Disp_Error

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!