clear all
t=linspace(0.01,10,1000);       %Declaring the constants
n=2;        
Ka=5;
cmax=16;
t0=1.5;
t1=5;
t2=6;
t3=8;

ft=zeros(size(t)); %Nutrient concentration

for i=1:length(ft)      %generating data for nutrient as a function of time
    if t(i) < t0
        ft(i) = 0;          % where ft stands for f(t)
    else
        if t(i)>= t0 && t(i)<t1
        ft(i) = (cmax / (t1-t0))*(t(i)-t0);
        else
            if t(i)>=t1 && t(i) <= t2
                ft(i) = cmax;
            else
                if t(i)> t2 && t(i) <= t3
                    ft(i) = cmax+(cmax / (t2-t3))*(t(i)-t2);
                else
                    if t(i)> t3
                        ft(i) = 0;
                       
                end;
            end;
        end;
    end;
end;
end;

figure;
subplot(2,1,1);
plot(t,ft);
axis([0 10 0 10])
xlabel('time (s)');
ylabel('concentration of nutrients inside the bacteria');
title('Nutrient against time');

theta = ((ft).^n) ./ ( ((Ka)^n) + (ft).^n);     %The Hill function

figure;
subplot(2,1,2);
plot(t,theta);
title('Hill Function');
xlabel('time (s)');
ylabel('concentration of nutrients inside the bacteria');
axis([0 10 0 1])