function plotFit( tpoint, Sdata,k)

%differential equations to describe the system's behaviour
S0 = k(11:14);
    function dS = activation_red(t,S)
         dS = zeros (4,1);
        dS(1)= k(1) - k(2) .* S(1)-k(5).*S(1).*S(2); %Cas
        dS(2) = k(3) - k(4) .* S(2)-k(5).*S(1).*S(2);  %tr/crRNA                                
        dS(3) = k(5).*S(1).*S(2) - k(6) .* S(3); %tr/crRNA/Cas9
        dS(4)= k(7) + k(8).*(S(3)./(k(9)+S(3))); %SEAP
    end

%Solve the differential equation by using the ode15s solver
[tsol,ssol]=ode15s(@activation_red,tpoint,S0);

%plot the graphs for the different substrates
figure(1)
for i = 1:2
    subplot(1,2,i)
    if (i == 1)
    plot(tpoint,Sdata(:,1:2),'S','MarkerSize',10);
    set(gca,'Color',[0.208 0.208 0.208]);
    legend('Cas9_1','Cas9_2')
    hold on
    plot(tpoint,k(10)*ssol(:,i),'x');
    hold off
    ylabel(['S(' num2str(i) ')']);
    elseif (i == 2)
    plot(tpoint,Sdata(:,3:4),'S','MarkerSize',8,'MarkerEdgeColor',[0.4 1 0.8], 'MarkerFaceColor',[0.4 1 0.8]);
    set(gca,'Color',[0.208 0.208 0.208]);
    legend('SEAP1','SEAP2')
    hold on
    plot(tpoint,k(10)*ssol(:,4),'x','MarkerSize',8,'MarkerEdgeColor',[0.4 1 0.8], 'MarkerFaceColor',[0.4 1 0.8]);
    hold off
    ylabel(['S(' num2str(i) ')']);
    else
        plot(tpoint, ssol(:,i));
        set(gca,'Color',[0.208 0.208 0.208]);
        ylabel(['S(' num2str(i) ')']);
    end
    drawnow
end
end
