I plan on using the switch command to use multiple chunks of code with differing ODE methods. Depending on what the user inputs as the 'diff' the code will run a specific chunk of code. Any ideas as to why this function isn't returning anything when I enter ODE(@(x,y)x^2,1,2,4,7,1) in to the command window? I've tried reassigning the output variables in the first line but to no avail.
function [x1,y1] = ODE(f,x0,y0,xn,h,diff)
%h = step size
switch diff
case '1'
h=(y0-x0)/xn;
y1=zeros(1,xn+1);
x1=x0:h:y0;
y1(1)=x0;
for j=1:xn
k1=feval(f,x1(j),y1(j));
k2=feval(f,x1(j+1),y1(j)+h*k1);
y1(j+1)=y1(j)+h*(h(1)+(h/2)*(k1+k2));
end
r=[x1',y1'];
return
end