We introduce a dynamic battery model that describes the variations of the capacity of a battery under time varying discharge current. This model supports a co-design approach for cyber-physical systems where control laws, online scheduling algorithms and battery management can be designed jointly to balance performance of the plant, the computing device, and the batteries. The input-output relationship of our model is equivalent to the RakhmatovVrudhula-Wallach (RVW) model that has been verified by high fidelity simulations and experiments. The major improvement of our model is that it allows online prediction of battery life. This improvement is significant since for cyber-physical systems, control laws and online scheduling algorithms draw current from batteries according to the state of the plant and the processor, which cannot be determined at the design stage. Using our model, the optimal discharge profile for a square wave current are determined and simulation results are pr...