clc, clear all, close all
[T,n] = ode45(f,t,N0(i));
subplot(2,2,i), plot(T,n), hold on
title({'N'' = N - cN^2',sprintf('c = %.1f, N_0 = %.1f',c, N0(i))}),xlabel('t'), ylabel('N(t)'), hold on
NE(1,j+1) = NE(j) + h*f(':',NE(j));
ErrorEuler(j) = abs(n(j) - NE(j))/n(j)*100;
plot(t,NE,'r-.'), hold on
K2 = f(t(j) + h*0.5, NRK(j) + h*K1*0.5);
K3 = f(t(j) + h*0.5, NRK(j) + h*K2*0.5);
K4 = f(t(j) + h, NRK(j) + h*K3);
NRK(j+1) = NRK(j) + h*((K1 + K4)/6 + (K2 + K3)/3);
ErrorRK(j) = abs(n(j) - NRK(j))/n(j)*100;
plot(t,NRK,'b.'), legend({'Exact solution','Euler''s method','Runge - Kutta'},'Location','Southeast')
plot(NE(1:end-1),ErrorEuler,'.')
plot(NRK(1:end-1),ErrorRK,'-.')
title({'N(t) vs. Error',sprintf('N_0 = %.1f',N0(i))}), xlabel('N(t)'), ylabel('Error (%)')
legend({'Euler','Runge - Kutta'})