%% INPUT -----------------------------------------------------------------+
a = 0; % left time interval limit
b = 20; % right time interval limit
N = 100; % number of points
tol = 1e-6; % tolerance
mu = 1; %.7; % parameter
f = @(t,x) [x(2);-x(1)-mu*(x(1)^2-1)*x(2)]; % function f
%% SOLVER ----------------------------------------------------------------+
x0 = [0.1:0.2:2;0.4:0.2:2.3];
newmap = jet(size(x0,2));
figure('Position',[500 500 420 500]);
lw = 2;
for ii = 1:size(x0,2)
    [t,x,error] = RKF45(a,b,x0(:,ii),N,tol,f); % Runge-Kutta-Fehlberg 4th order adaptative scheme
    plot(x(1,:),x(2,:),'Color',newmap(ii,:),'LineWidth',lw); hold on;
end

x0 = [-(0.1:0.2:2);0.4:0.2:2.3];
newmap = jet(size(x0,2));
for ii = 1:size(x0,2)
    [t,x,error] = RKF45(a,b,x0(:,ii),N,tol,f); % Runge-Kutta-Fehlberg 4th order adaptative scheme
    plot(x(1,:),x(2,:),'Color',newmap(ii,:),'LineWidth',lw); hold on;
end

x0 = [-(0.1:0.2:2);-(0.4:0.2:2.3)];
newmap = jet(size(x0,2));
for ii = 1:size(x0,2)
    [t,x,error] = RKF45(a,b,x0(:,ii),N,tol,f); % Runge-Kutta-Fehlberg 4th order adaptative scheme
    plot(x(1,:),x(2,:),'Color',newmap(ii,:),'LineWidth',lw); hold on;
end

x0 = [0.1:0.2:2;-(0.4:0.2:2.3)];
newmap = jet(size(x0,2));
for ii = 1:size(x0,2)
    [t,x,error] = RKF45(a,b,x0(:,ii),N,tol,f); % Runge-Kutta-Fehlberg 4th order adaptative scheme
    plot(x(1,:),x(2,:),'Color',newmap(ii,:),'LineWidth',lw); hold on;
end
%% FORMAT OUTPUT ---------------------------------------------------------+
xlabel('x1');
ylabel('x2');

axis([-3 3 -4 4]);
ax = gca;
ax.XTick = -3:1:3;
ax.YTick = -4:1:4;
set(ax,'TickLabelInterpreter','latex');

set(gca,'fontsize',16)
str='$x$';
xlabel(str,'interpreter','latex','FontSize',20);
str='$x^{\prime}$';
ylabel(str,'interpreter','latex','FontSize',20);

tightfig;