Battery State of Charge Estimator

Hard MATLAB Estimation Asked at Rivian
Solve this problem

Estimate a lithium cell's state of charge by blending coulomb counting with an open-circuit voltage lookup, so the estimate neither drifts nor jumps under load.

Constraints

  • Inputs are current and terminal voltage sample vectors plus the cell capacity.
  • Coulomb counting integrates current; OCV lookup corrects the drift.
  • Only trust the OCV reading when the current is near zero.
  • Blend with a slow correction gain so the estimate does not jump.
  • Clamp the result to 0 to 100 percent.
  • Return the SoC trajectory.
Starter codeMATLAB
1function soc = estimate_soc(current, voltage, capacity_ah, dt)2% TODO3end