battery charging simulation in matlab