% M-file to
% - compute the least squares regression curve for the Lemna minor data
% Data
t = 0:4:12;
%FW = [0.0416 0.1008 0.2937 0.9588]; %mineral growth medium
FW = [0.0416 0.0592 0.1006 0.1717]; % domestic waste water
% Find the equation of the LSR curve using ln(FW) & corr coeff
C = polyfit(t,log(FW),1);
rho = corrcoef(t,log(FW));
fprintf('Eqn for LSR: FW = %6.4f e^(%6.3f t), R^2 = %f\n',...
exp(C(2)),C(1),rho(1,2)^2)
% Approximate the slope for values t = 2:2:12
that = 2:2:12;
for i = 1:length(that)
FW_prime(i) = ...
( exp(polyval(C,that(i)+2)) - exp(polyval(C,that(i)-2)) ) / 4;
end
% The derivative data is that and FW_prime
% Find the equation of the LSR curve using ln(FW_prime)
C_prime = polyfit(that,log(FW_prime),1);
rho_prime = corrcoef(that,log(FW_prime));
fprintf('Eqn for LSR: FW_prime = %6.5f e^(%6.3f t), R^2 = %6.4f\n', ...
exp(C_prime(2)),C_prime(1),rho_prime(1,2)^2)