function [I] = BattChargeCurrent(V,T,S,N,C)
%arguments
%V = Voltage
%T = Temperature (0 = cold. 1 = hot).
%S = State of Charge - 0 = fully discharged (1.75V/cell)
%                      1 = fully charged (2.33V/cell)
%N = number of Pb Cells
%C = capacity of each cell (A-hr)

m = 2.5*T+0.5;  %Slope of I/V line, depends on temperature

b = (10.5+S*(14-10.5))/6;  %Zero current voltage, depends on state of charge

I = (V-N*b)*m*C/N;

idx = find(I<0);
I(idx) = 0;



end

