Not enough Input arguments (Adaptive RK method )
Info
This question is closed. Reopen it to edit or answer.
Show older comments
The photo attached is the question. Here is my script answer but error shows me that it has not enough input arguments in line 15. Can someone help me to fix this?
function[t,y]= P3(dydt,tspan,y0,h)
tspan=[0 4];
y0=0.5;
h=0.1;
ti=tspan(1);
tf=tspan(2);
t=(ti:h:tf)';
n=length(t);
if t(n)<tf;
n=n+1;
end
y=y0*ones(n,1);
for i=1:n-1
hh=t(i+1)-t(i);
k1= feval(dydt,t(i),y(i));
ymid=y(i)+k1*hh/2;
k2=feval(dydt,t(i)+hh/2,ymid);
y(i+1)=y(i)+k2*hh;
end
plot(t,y)
end
Not enough input arguments.
Error in P3 (line 15)
k1= feval(dydt,t(i),y(i));
1 Comment
Stephen23
on 28 Nov 2019
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!