function [lf,dlf]=lf_func(T,TStart,TFinal)


%TFinal and Tstart in Celcius

T0=273.15+TStart;

TKFinal=273.15+TFinal;

lf=(T-TKFinal)/(T0-TKFinal);
%alternative cubic function with freezing starting at -4C
%lf=1+2/(TFinal+4)^3*((T-T0).^3-3/2*(TFinal+4)*(T-T0).^2);
lf(T<=TKFinal)=0;
lf(T>T0)=1;

dlf=ones(size(T))/(T0-TKFinal);
%alternative cubic function
%dlf=2/(TFinal+4)^3*(3*(T-T0).^2-3*(TFinal+4)*(T-T0));
dlf(T>T0)=0;
dlf(T<=TKFinal)=0;





