ode45 Not enough input agruments

2 ビュー (過去 30 日間)
Rick J
Rick J 2016 年 10 月 30 日
コメント済み: Walter Roberson 2016 年 10 月 30 日
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!!!

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 10 月 30 日
Probably you need
f_count(@Disp_Error,10,1,0.0001)
  2 件のコメント
Rick J
Rick J 2016 年 10 月 30 日
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 2016 年 10 月 30 日
We will need to see Disp_Error

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by