%t_jamv = [1.4e5 1.5e4 4500 1400 550 300 300]
Tspan = linspace(0,1e7,1000);
Et = 0.1;
k=1;

%for pH = 0:.1:7
   pH = 6   
   H  = 0;%10^(-pH);
   S  = 2; 
   [t u] = ode15s('diff', Tspan, [1 H 0 Et S 0 0]);
%   E(k)   = u(1000,4);
%   EH(k)  = u(1000,1);
%   EH2(k) = u(1000,3);
%   k=k+1;
% end
 
%figure(1)
%plot(0:.1:7,EH,0:.1:7,E,0:.1:7,EH2)
%legend('EH^+','E','EH^2^+')
%grid

figure(1)
plot(t,u(:,1),t,u(:,5),t,u(:,7),t,u(:,6),t,u(:,1)+u(:,6),'--',t,u(:,8))
legend('E','S','P','ES','E_t','P_M')
xlabel('tid(s)')
ylabel('Koncentration (M)')
title('Ribonukleas c) ii)')
grid

%figure(2)
%plot(t,u,t,u(:,1)+u(:,6),'--')
%legend('EH^+','H^+','EH^2^+','E','S','EH^+S','P','E_t')
%grid
%xlabel('tid(s)')
%ylabel('Koncentration (M)')
%axis([0 7 0 1.1e-4])


%b) i)
%plot(t,gradient(u(:,6),t))
%title('Gradienten av enzymkomplexet ES')
%xlabel('Tid(s)')
%ylabel('d[ES]/dt (M s^-^1)')
%grid

%Minsta kvadratmetoden
%A  = [1./u(:,5) ones(1000,1)];
%y  = 1./gradient(u(:,7),t);
%b  = A\y;
%k2 = 1/(Et*b(2))
%KM = b(1)*k2*Et

%Feluppskattning c) iii)
%P  = u(:,7);
%PM = u(:,8);
%figure(2)
%plot(t,P,'r--',t,0.95*P,'r--',t,PM);
%title('Feluppskattning av Michaelis-Mentens ekvation')
%legend('P','0.95P','P_M (E_t=10^-^1)')
%xlabel('Tid(s)')
%ylabel('Koncentration (M)')
%grid


