% This script finds numerically when pollution level exceeds 2 ppm
% Divide the time evaluation into steps of 0.1 (20,000 steps)
ts = [0:0.1:2000];           
[t1,y1] = ode23(@lake2,ts,0); % Simulate the model (lake2) at given times (ts)
n = 1; yc = y1(n);           % Initialize y for comparison to 2 ppm
while (yc < 2)              % Continue executing this loop until yc > 2
    n = n+1;                % Increase the index
    yc = y1(n); tc = t1(n);   % Reset the yc and tc value to the new solution value
end
sprintf('t = %.1f.', tc)    % Print out the critical t value
