Index Error while writing a function to call ODE's

1 view (last 30 days)
I am writing a code that uses the switch function to call various methods to solving ODEs. Every time I call the function I get a ton of errors. The first one is always "index exceeds matrix dimensions" and the rest just point to certain lines. How do I get rid of the first error?
switch value
case 0
method=@Emethod;
case 1
method=@Rmethod;
end
for i=1:N
y(i+1)= method(y(i),f,x(i),h);
x(i+1)=x(i)+h;
end
*In a different tab I have the equations for Emethod and Rmethod . For example:*
function y = Emethod(y,f,x,h)
k1 = f(x(i),y(i)); y(i+1) = (y(i)+h*k1);
end
*There also seems to be a problem with the line for k1*
Any suggestions?

Answers (0)

Community Treasure Hunt

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

Start Hunting!