I have a differential equation which I want to solve using Euler method.
I created a script which has only the equation:
function dx=differential (t,x);
And another script in order to implement Euler's method
f = input('differential.m'); % Enter the function right to the ODE
t0 = input ('Enter initial value of time'); % Value that time starts
x0 = input ('Enter initial value of x'); % Initial condition
tn = input ('End point of time'); % Value that time ends
h = input ('Enter step size'); % TIme step value
% Euler method & Initial conditions
% Euler Loop
x(i+1) = x(i) + h*f(t(i),x(i));
t(i+1) = t0 + i*h;
I want when I press play to the script of Euler's solution, instead of putting the differential equation manually, to call it direclty from the script which includes the equation.
How can I do this, and in which form should the equation be written in order to achieve this?
Thank you very much