File Exchange

image thumbnail

Machine Learning Lithium-Ion Battery Capacity Estimation

version (763 KB) by Wanbin Song
Machine learning based Lithium-Ion battery capacity estimation using multi-Channel charging Profiles


Updated 07 Jan 2020

From GitHub

View Version History

View license on GitHub

In this script, I've implemented machine learning based Lithium-Ion battery capacity estimation using multi-Channel charging Profiles. Dataset used in this example is from "Battery data set" from NASA[1].
Basic implementation theory and approach is referenced by the recent published paper[2], and they proposed Multi-Channel charging profiles based machine learning and deep learning model for capacity estimation. Through this example, I will capture each approach described in paper.

[1] B. Saha and K. Goebel (2007). "Battery Data Set", NASA Ames Prognostics Data Repository (, NASA Ames Research Center, Moffett Field, CA
[2] Choi, Yohwan, et al. "Machine Learning-Based Lithium-Ion Battery Capacity Estimation Exploiting Multi-Channel Charging Profiles." IEEE Access 7 (2019): 75143-75152.

Cite As

Wanbin Song (2021). Machine Learning Lithium-Ion Battery Capacity Estimation (, GitHub. Retrieved .

Comments and Ratings (12)

srinivas s

B0005.mat not in the source code, code is not running sir i am getting the following error

Error in extract_discharge (line 2)
bcycle = B.cycle;

Srinivas P

Hi Song
Thank you for the response and useful links that you sent me.

Wanbin Song

Thanks for the interest and apologize for the delayed response.
There are many parameters that can cause a neural network to stop training. As you may know, an epoch is the full pass of the training algorithm over the entire training set. In general, the training will stop before reaching the specified maximum number of epochs to avoid overfitting to the data, thus improving the network generalization. That is, the training will stop if the results of the cross-validation are not getting any better (within some tolerance).
Please refer to the following link for more information on the early stopping behavior to improving generalization of the network:

Also please refer below link for continued training without considering the overfitting.

Srinivas P

Hi Song
I also ran the program for FNN 40 and the iterations stopped at 12. Why is that it is not completing all iterations.What should be the plot interval. How can one tune the NN and I appreciate if could suggest any pointers to the same in MATLAB. Why is that I got different Real Value curve for FNN10 and FNN40.
Thanks in advance for your suggestions

Srinivas P

Hi Song
I try run the code given by you for FNN with 10 and training stopped after 7 iterations. Could you please explain me about this as I am taking baby steps in machine learning using MATLAB.

Takuji Fukumoto


Thank you Wanbin Song

Wanbin Song

Seems the error is related with the implicit expansion which we support since R2016b and later.
If you are using earlier version, please change the code as below:
>>xData = bsxfun(@minus, charInput, min(charInput))./r;
You can find details in below:


i got an error in minmax_norm function in line (xData = (charInput - min(charInput))./r;) stating that the size or dimension of charInput is not same as min(charInput).


Hi Wanbin Song will this code run only for the latest version of MATLAB or earlier one also.

Wanbin Song

Hi Wenxian,
Thanks for the input. Due to limited dataset available, I've just focused on implementing proposed methods on the paper(FNN, CNN, LSTM), but not exactly the same with them.
I've updated my files, and it includes 'Divide dataset into Train/Validation/Test set to avoid overfitting'.
Now it would be more reasonable.


You just fit the curve, not predict the future capacity. You only see the training set, not the test set. It's equivalent to throwing the data of training set into neural network for training again.Do you have contact information? I want to talk about some problems

MATLAB Release Compatibility
Created with R2019b
Compatible with R2019b and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!