code of Euler's
5 views (last 30 days)
Show older comments
function edoeuler_v2(f,t0,tf,p0,h)
t = [t0:h:tf]';
n=length(t);
if t(n)<tf
t(n+1)=tf;
n = n+1;
end
p= p0*ones(n,1);
for i = 1:(n+1)
p(i+1) = p(i) + h*f(t(i),p(i));
end
salida=[t p];
output(salida)
end
And then i got this in the command view
edoeuler_v2(@(p)0.0169*t,0,5,0.03,1)
Error using @(p)0.0169*t
Too many input arguments.
Error in edoeuler_v2 (line 10)
p(i+1) = p(i) + h*f(t(i),p(i));
0 Comments
Answers (1)
Walter Roberson
on 25 Nov 2020
@(t,p)0.0169*t
2 Comments
Walter Roberson
on 25 Nov 2020
Somehow you changed your file edoeuler_v2 so that it no longer starts with
function edoeuler_v2(f,t0,tf,p0,h)
See Also
Categories
Find more on Language Fundamentals 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!