% apple_worse.m : a variant of apple_bad.m to illustrate that MATLAB % wants the first function to be the main function % Even if there is an explicitly declared function named apple_worse % This file produces the following error upon typing: % sol_two_worse = apple_worse(1,2,100,3) % Error: File: apple_worse.m Line: 24 Column: 1 % Function 'apple_worse' has already been declared within this scope. function two_y = f(t,y) two_y = 2 * y end function result = orange(t_0,t_end,N,y_0) h = (t_end - t_0)/N t = [t_0 : h: t_end] y(1) = y_0 for i=1:N y(i+1) = y(i) + h * f(t(i),y(i)) end result = y end function result = apple_worse(t_0,t_end,N,y_0) h = (t_end - t_0)/N t = [t_0 : h: t_end] y(1) = y_0 for i=1:N y(i+1) = y(i) + h * f(t(i),y(i)) end result = y end