Uploaded September 2025 | Updated November 2026, 3 hours ago
Learn how MATLAB® that can be used to develop and compress an AI model for battery state-of-charge (SOC) estimation, then deploy it to a microcontroller for real-time use in a battery management system (BMS).
With a single line of MATLAB code, you can generate standalone, generic C or C++ code for deep learning models created in MATLAB or imported from other frameworks. Begin by constructing and training a long short-term memory (LSTM) deep learning network for battery SOC prediction using the Deep Network Designer app in MATLAB. Then, apply neural network projection to compress the network by over 90%, optimizing it for efficient execution on a resource-constrained microcontroller. Finally, generate generic C code for the compressed LSTM model using the MATLAB Coder™ app. Once code generation is complete, the generated C code can be integrated with the remaining BMS firmware to predict SOC in real time.
The data set used for battery SOC estimation in this example can be found in [1]:
[1] Eleftheriadis, Panagiotis. “PoliMi-TUB Dataset - LG 18650HE4 Li-Ion Battery.” Mendeley Data, V1, 2024. bit.ly/3HOQLSf
Learn more:
- MATLAB and Simulink for Embedded AI: bit.ly/4g21mIh
- Compressing Neural Networks for Embedded AI: youtu.be/7uV3-eTB5es
- A Practical Introduction to Edge AI: youtu.be/ibm6ZRi6Sm4
--------------------------------------------------------------------------------------------------------
Get a free product trial: goo.gl/ZHFb5u
Learn more about MATLAB: goo.gl/8QV7ZZ
Learn more about Simulink: goo.gl/nqnbLe
See what's new in MATLAB and Simulink: goo.gl/pgGtod
© 2025 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc.
See mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.
Learn how MATLAB® that can be used to develop and compress an AI model for battery state-of-charge (SOC) estimation, then deploy it to a microcontroller for real-time use in a battery management system (BMS).
With a single line of MATLAB code, you can generate standalone, generic C or C++ code for deep learning models created in MATLAB or imported from other frameworks. Begin by constructing and training a long short-term memory (LSTM) deep learning network for battery SOC prediction using the Deep Network Designer app in MATLAB. Then, apply neural network projection to compress the network by over 90%, optimizing it for efficient execution on a resource-constrained microcontroller. Finally, generate generic C code for the compressed LSTM model using the MATLAB Coder™ app. Once code generation is complete, the generated C code can be integrated with the remaining BMS firmware to predict SOC in real time.
The data set used for battery SOC estimation in this example can be found in [1]:
[1] Eleftheriadis, Panagiotis. “PoliMi-TUB Dataset - LG 18650HE4 Li-Ion Battery.” Mendeley Data, V1, 2024. bit.ly/3HOQLSf
Learn more:
- MATLAB and Simulink for Embedded AI: bit.ly/4g21mIh
- Compressing Neural Networks for Embedded AI: youtu.be/7uV3-eTB5es
- A Practical Introduction to Edge AI: youtu.be/ibm6ZRi6Sm4
--------------------------------------------------------------------------------------------------------
Get a free product trial: goo.gl/ZHFb5u
Learn more about MATLAB: goo.gl/8QV7ZZ
Learn more about Simulink: goo.gl/nqnbLe
See what's new in MATLAB and Simulink: goo.gl/pgGtod
© 2025 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc.
See mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.










