%%

%Ordinary differential equations
%E.g. ode23 function uses Runge-Kutta method (combination of 2nd and 3rd order, 
%higher order is used to calculate the following function value and lower order is used to estimate the error)

%initial value
y0 = 1;
%Rough division of the interval [0,0.3]
division = 0:0.1:0.3;
%plots the solution
ode23('fun1',division,y0)
%saves the solution
[x,y] = ode23('fun1',division,y0)

%Smooth division of the interval [0,0.3]
division_smooth = 0:0.01:0.3;
%plot the solution
figure %figure new window
ode23('fun1',division,y0)
%saves the solution
[x_smooth,y_smooth] = ode23('fun1',division,1)

%True solution
fun_true = @(x) -2*x-2+3*exp(x)

%plots numerical and true solution of ODE into one figure
figure 
ode23('fun1',division_smooth,y0)
hold on
plot(division_smooth,fun_true(division_smooth),'r')
hold off