File Exchange

image thumbnail

Battery Modeling

version 1.27 (2.16 MB) by Javier Gazzarri
Lithium ion battery characterization, state estimation, cell balancing, and thermal management


Updated 03 Jun 2021

View Version History

View License

Editor's Note: Popular File 2020

This file contains Simscape Electrical Lithium-ion battery models for parameter estimation and simulation.
1. Unzip the project.
2. Double-click BatteryModeling.prj to set up the MATLAB path. The html index contains links to open each example.
1. 3S-1P battery pack CCCV charge with passive balancing using Simscape Electrical. Charge / discharge cycling with passive balancing, including thermal effects.
2. EV battery cooling. Liquid cooling of an automotive battery pack.
3. Cell characterization. Parameter estimation of single cell using pulsed discharge experiments.
4. SOC Estimation using UKF.
5. SOH (internal resistance) online estimation using EKF. Internal resistance grows over time and the nonlinear Kalman Filter estimates its evolution.
6. Battery App. This app can be used to find battery parameters from datasheet information.
This site contains additional information on battery modeling using MathWorks(R) tools:
Additional literature:
SAE 2015: Model-Based Parameter Identification of Healthy and Aged Li-ion Batteries for Electric Vehicle Applications
Webinar: Battery Data Acquisition and Analysis Using MATLAB
Webinar: Lithium Battery Model with Thermal Effects for System-Level Analysis
IEEE 2012: Lithium Battery Model with Thermal Effect
SAE 2013: Simplified Extended Kalman Filter Observer for Battery SOC Estimation
SAE 2013: Battery Model Parameter Estimation Using a Layered Technique
SAE 2014: Battery Pack Modeling, Simulation, and Deployment on a Multicore Real Time Target
Webinar: Optimizing Vehicle Electrical Design through System-Level Simulation
Video: Real-Time Simulation of Battery Packs Using Multicore Computers
Video: MATLAB & Simulink Racing Lounge: Battery Modeling with Simulink
Using Model-Based Design to Build the Tesla Roadster
MathWorks(R) Consulting offers services on this topic. For assistance, please contact me or your MathWorks(R) representative.

Cite As

Javier Gazzarri (2021). Battery Modeling (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (131)

Gaur Prateek

Good Morning, I have a small problem related to the same topic which I am unable to solve so I need your support. I am attaching the code for battery pack Aging, prepared by my but there are some problems with the time as the unit there is NOT days because no battery will age to 65% its original capacity during 8*10^-3 days. Please help me to solve this problem, I'll be highly thankful to you.



%% loading the OCV-SOC curve
load ocvSoc
f = polyfit(soc,ocv,20);

socTest = linspace(0, 100, 100);
ocvTest = polyval(f, socTest);
plot(soc,ocv, socTest, ocvTest);
title('OCV-SOC curve');
xlabel('SOC (%)')
ylabel('OCV (V)')
legend('Simulink model', 'Curve-fitted');

Ah = 3.5; % Ah

%% input time-soc profile

Crate = 0.3;
DOD = 0.6;
SOCavg = 0.5;
cycles = 4000;
time = (0:1:(2*cycles-1)).*(3600*DOD/Crate);
SOC = repmat([SOCavg+DOD/2 SOCavg-DOD/2], [1 cycles]);
T = 36.94+273;

plot(time, SOC)
title('SOC profile')
xlabel('time (s)')
ylabel('SOC (0 to 1)')

%% pre-process inputs to the aging model

vTrace = polyval(f, SOC*100);

V = mean(vTrace); % is it OCV or CCV?
quadVavg = sqrt(mean(vTrace.^2));
t = time(end)/3600/24; % time in days
Q = DOD*cycles*Ah; % do I have to multiply by 2 for charge?

ylabel('vTrace (1 to 2.5)')

%% aging model evaluation
% is it additive? NO
% Calendar aging coefficients
% V: voltage at the mean SOC
% T: cycle test temperature (Let's just take the average temperature)
alpha_cap = (7.534 * V - 23.75)*10^6*exp(1)^(-6976/T);
alpha_res = (5.270 * V - 16.32)*10^5*exp(1)^(-5986/T);

% Cycle aging coefficients
% quadVavg: quadratic average voltage (RMS voltage)
% DoD: depth of discharge (0 to 1)
beta_cap = 7.348*10^-3*(quadVavg - 3.667)^2 + 7.600*10^-4 + 4.081*10^-3*DOD;
beta_res = 2.153*10^-4*(quadVavg - 3.725)^2 - 1.521*10^-5 + 2.798*10^-4*DOD;

% Resulting function, Crel and Rrel are relative capacity and resistance
% respectively
% t: time in days
% Q: charge throughput in ampere hours (how much charge has been moved in
% and out)
%CcycleRel = beta_cap * sqrt(Q);
%RcycleRel = beta_res * Q;
Crel = 1 - alpha_cap * t.^0.75 - beta_cap .* sqrt(Q);
Rrel = 1 + alpha_res * t.^0.75 + beta_res .* Q;

disp(['Crel: ' num2str(Crel)])
disp(['Rrel: ' num2str(Rrel)])

%% This cell is to plot aging pattern over time

t = (0:1:cycles).*(3600*DOD/Crate*2/3600/24);
Q = (0:1:cycles).*DOD*Ah;

%CcycleRel = beta_cap * sqrt(Q);
%RcycleRel = beta_res * Q;
Crel = 1 - alpha_cap * t.^0.75 - beta_cap * sqrt(Q);
Rrel = 1 + alpha_res * t.^0.75 + beta_res * Q;

plot(t/3600/24, Crel)
title('Relative Cap')
xlabel('time (days)')

Fahmi Naim

Hi I have a question since I new with Matlab, How i want to use passive balancing and install it into my hybrid electric vehicle model. Do I need coding because I have 10 cells

Youngchen Zhang

Great project! I hope there will be more kinds of batteries in your next version.

Wolfgang Frauhammer

Is there an older version of this model, so that i can run it on 2013b? Thank you!

Kai Yuan

Sergei Turovets

When trying to run Demo 2 - EV battery cooling - I am, getting an error: " Unrecognized function or variable 'sscfluids_ev_battery_cooling'. "

When trying to run Demo 3 -Cell characterization - I am getting also and error : " Error using open (line 80)
File 'batteryParameterEstimation.slx' not found."
Please add these files in the package for downloads.

Phuong Thao Bu

Good morning,
I have a question about the model. Is this model only suitable for Lithium battery or also for another battery? I am trying to bild a model for a Redox-Flow-Battery.
Thank you


gyubaek lee


yi lin


@srikanth dabbikar, from matlab applaication we can use the file, after open it needs to extract the file, it will automatically open.

Srikanth Dabbikar

Hi I am unable to open this files..Can you help me

Farhan Nizam

How to download it?

Christopher Harrison

Are some of the layers of "batteryParameterEstimation" Simulink protected and unable to be modified? I would like to change the exponential calculations.

Bibinsha M M

I am getting following error while opening the project file BatteryModeling.PRJ 'Unable to find a definition folder for the project in resources/project error'

Downloaded and extracted files. Also installed all support packages needed.

I am using Matlab 2020b. Please help.

Wen Yuan


@Justyna Plotek, no you cannot because there is no data from SoC zero

You Gong

Je-Min Son


I was hoping to use the model to mainly estimate SoC of my battery experiment data (time, current, voltage). How can I use my experimental values instead of the saved ones in the model?

xu ding

It's helpfull for my work, thank you very much!

Mudit Verma

.mlproj not opening please provide another extensions in

Ever Berrio

Justyna Plotek

Is it possible to make parameter estimation for SoC of battery lower than 0.1?
Thank you for the model. It is great!

prajod k

the files are prepared on 2019b. How can i open the files in 2019a

sanya gode

@javier gazzarri sir, I started working on Battery Modeling and the models developed by you are very helpful. It gave me an excellent undersstanding of how to model batteries. But I have few doubts -
In the model SOH estimation, why haven't we used an Unscented Kalman FIlter but an Augmented Extended Kalman Filter ?
What is the significance of the 'Noise Subsystem' which has moving averages of current and voltage noise.
The current profile EKF.mat MATLAB data file has been imported from some experimental data ? Can you please explain that what is time and current signal value in this data exactly. How does the online parameter estimation calculates R0 based on state and measurement update functions.
Also can I include this model for my thesis work sir.

Harish SM

Javier Gazzarri

@eduardo: thank you for your question. The EV cooling demo ships with MATLAB therefore it is not needed as part of the submission. You just need to type sscfluids_ev_battery_cooling at the MATLAB Command Window.


Hi Javier,

Thank you for your model. The EV cooling demo seems to be missing from the zip. All the other content is available.
I was wondering if you could make the cooling available as well. Much apprecaited.

Kind Regards

Mou Xu

jonathan moura

Hi Mr. Gazzarri,

some files require a newer version of Simulink. Would it be possible to make it available? In my case I use matlab 2018 and I can't run .mlprj

Thanks & best regards.

Xiaobo dong

Shirin Phadke

Hi! Dear Sir,
The files have an extension of .mlproj which matlab2019a is not able to process. Is there any other way to open them?


Dear Javier, in response to one of your comments when recommending using a pulse discharge for estimation and 'drive cycle' for model validation, do you agree with me that the battery parameters and the output are also function of the C-rate ( i.e. current profile) not just the temperature and SoC. That is why for example in the literature, it is stated that the ECM will never be valid outside the operating conditons used because we do the paramter estimation for the current vs voltage exp data then we fit the model. But if we change the current profile to diffeent one espically when charging using higher c-rates, I don't think the model will be valid even if validated using some random driving cycle. Thanks

Nicolas Basquera

Is it possible to access older versions of the simulations?

I have a 2018 matlab and cannot run .mlprj


Steve Cheugueu

Javier Gazzarri

@Joao Paulo Fumagalli: After doing the estimation it is important to validate the parameters using a data set different from that used for estimation. An acceptably low validation error indicates that the model is capable of reproducing a general current profile. Hence the importance of using estimation datasets that adequately exercise the parameters throughout the entire SOC and temperature range of interest. I typically recommend a pulsed discharge for estimation and a drive cycle for validation.

Md Salimullah


Hi. I extended the simulation to include 2RC but it takes ages the converge or estimate the parameters.


apei zou

Dear genius:
It's my great honor to read your article. I'm working on the battery management system. Now I'm working on battery system modeling and battery parameter estimation. I hope I can ask you a few questions. Whether the gradient descent or Newton method is used to estimate battery parameters. How to improve the calculation speed of parameter estimation? What are the commonly used methods in the on-line SOC parameter engineering of real vehicles? How do these algorithms work in the actual engineering? What practical literature and information should I track?

Hello gentlemen,
I am using the model Mr. Gazzarri developed with only a modification in the data. My doubt is: with the parameters estimated and a random current curve, can I predict the voltage behavior or the model cannot do this kind of thing?

Thanks for all the help.

Bo Huang

Lennard Schulze

Is it possible to implement an other thermal model ? For example a thermal model based on a 2-RC branch, where one branch represents the cell core and the other branch the cell surface (as Forgez explained in "Thermal modeling of a cylindrical LiFePO4/graphite lithium-ion battery").
How is the thermal dependence between the cells represented? And how can other thermal dependencies, e.g. between cells and the case, been representing?

Best regards and thank you in advance.


How did you insert the ORANGE block and link the orange block to the parameter estimation gui?

Xiaojie Qiu

Javier Gazzarri

@Jon Ostolaza: A few things to consider for initial condition improvement. 1) If your experiment has relatively long periods of time at open circuit (i=0), you can calculate the state of charge up to each of them (coulomb counting from the initial SOC) and use these SOC values as breakpoints for the SOC_LUT vector, and the OCV value at the end of the rest period as initial condition for Em. 2) If the experiment exhibits sudden changes in current, you can also manually calculate the initial R0 by doing R0 = delta_V/delta_I every time you have a current step change. 3) There is a Sensitivity Analysis function in Simulink Design Optimization that you can use to perform a quick Monte Carlo analysis to estimate sensitivity. 4) Would you be able to share a screenshot of the superposition of the experiment and the simulation at the end of the analysis so I can try to elucidate the convergence error?

Jin Kusaka

@javier gazzari sir, I would like to know how you have given the values of Resistance R0, R1 and capacitance C1 in a matrix format in the program for lithium battery 80 cell in series. Is it experimental data?

Jon Ostolaza


I am using this model to estimate the battery model parameters using my lab test results. When I do the parameter estimation the algorithm converges to an error of 0.08 leading to a missmatch between simulated and measured curves. I am wondering if this is a local minima problem. I would also like to know how sensitive the model is to initial conditions and what would be an smart way to estimate these initial conditions to obtain a better fitting of the model.

Thank you in advance!!!

Pradipta Kumar Pal

Javier Gazzarri

@Qihong: That message indicates the absence of a Simulink Design Optimization license.

Jin Kusaka

The model says it the example requires 2017a, i would like to ask if would work on 2018a?

Kim Sommer

The model info on this page says it requires 2017a but also
"Created with R2012a
Compatible with any release "

We are locked in at 2016a for the forseeable future and cannot open this model. Is there a version possible that can be opened with earlier versions?

Thank you

Will He

The SOC can be smaller than 0?
In em_table.ssc, I find the code to prevent SOC>1 ('if Qe<0 && i>0 Qe.der == 0;'). The simulation gets stuck after I change the condition to 'if (Qe<0 && i>0) || (Qe>C && i<0) Qe.der == 0;'(of course I move the C calculation before the condition).
I can't understand why this condition can prevent SOC>1, and will not work when preventing SOC<0.
Thank you for your work.

Murtaza Pasha

Thank you for this post. I tried to work on 'ssc_lithium_cell_1RC estim', however, when I try to estimate the parameters, while I hit the orange button, it doesn't take me to the parameter estimation session, instead, an error message shows up. What's the best way to resolve it? Please, let me know, Thanks.

Qihong Nie

Error evaluating ‘OpenFcn’ callback of SubSystem block (mask)
‘ssc_lithium_cell_1RC_estim/Open GUI’. Callback string is ‘%
Ssc_lithium_cell_1RC_estim’,’One Temp Estim’);

Undefined function ‘speload’ for input arguments of type ‘char’.

Qihong Nie

please let me know what is wrong with this error message!



fadi safadi

Hi there am getting this error when I run the simulation:

Error evaluating parameter 'C_Table' in 'ssc_lithium_cell_1RC_estim/lithium ion cell (1-RC equivalent circuit model, isothermal)/C1'

is there a solution for this?

Shailesh Sonalikar

Isaac Thompson

the "requirements" section now says 2017a is required, as well as the parallel computing toolbox. will this still run on 2016b, and without the parallel computing toolbox?

Olcay Sari

Javier Gazzarri

@Juan Villegas Ceballos
We created synthetic data for this example because the data presented in the paper is proprietary. Hence the change from 31 Ah (original) to 27.625 Ah.


Hi, I have a Primary problem about these simulation. How can I import the data for the singnal builder of current and ambient temperature ? i'm a college student ,and i want to learn about the subject.thanks.

Kazuaki Kisu

I also get this question. I'd like to know the answer.

Ali Baheri

Hi, I have a general question about these files. How can I use set_param command in Simspace if I want to change battery parameter from a script? In fact, I have written my optimization algorithm, and I want to change the battery parameter after one round of simulation from workspace. Thanks for helping in advance.

Renos Rotas

I get the same problem. Have you found any solution?


I am trying to run the R2012b sc_lithium_cell_1RC.mdl under R2017a. When I try and run I get the following errors.

Multiple compilation errors detected while compiling ssc_lithium_cell_1RC.
Caused by:
['ssc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/C1']: Cannot find parameter 'i'. Please run ssc_build if you have made changes to Simscape file or if you are upgrading to a new version of Simscape.
['ssc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/Em_table']: Cannot find parameter 'Qe'. Please run ssc_build if you have made changes to Simscape file or if you are upgrading to a new version of Simscape.
['ssc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/R0']: Cannot find parameter 'i'. Please run ssc_build if you have made changes to Simscape file or if you are upgrading to a new version of Simscape.
['ssc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/R1']: Cannot find parameter 'i'. Please run ssc_build if you have made changes to Simscape file or if you are upgrading to a new version of Simscape.

Subsequently I try to run the ssc_build on LiBatteryElements, BUT... that library doesn't exist in 2012b. However it is in 2010b. I copied it into my working directory and rerun sec_build. Now I see this:

Failed to generate 'LiBatteryElements_lib'

Caused by:
Error using LiBatteryElements.C_table>equations (line 43)
Function, tablelookup, is wrong. Please check 1) whether input data points have correct sizes; 2) query
values are scalar; 3) query values and table data have the commensurate units; and 4) constants or compile
time parameters are passed to interpolation and extrapolation argument.
Argument 1 = [5x1 double]
Argument 2 = {[273.1500 293.1500 313.1500], 'K'}
Argument 3 = {[5x3 double], 'F'}
Argument 4 = [1x1 double]
Argument 5 = {[1x1 double], 'C'}
SOC_Table = [5x1 double]
Temp_Table = {[273.1500 293.1500 313.1500], 'K'}
C_Table = {[5x3 double], 'F'}
SOC = [1x1 double]
T = {[1x1 double], 'C'}

I looked at the code but could not tell what was wrong.
Any ideas?

According to the file the battery used is 27.6 Ah, different from the referenced paper which use a 31Ah cell. I would like to know the reference of the cell with which the experimental curve was made.

Thank you

Ouettar Chikou

Sir I'd​ like to know if I can apply that model entitled "Lithium Battery Model, Simscape Language and Simulink Design Optimization" to simulate prismatic lithium ion batteries that are used in cell phones like (sumsung EB454357VU 1200mAh).

Thank you

Aditya Singh

When Implementing the 80 cell pack I am getting an error
'Provided units 'C' and 'K' are not commensurate.'

Can anyone please help me with it? Thanks in advance. If you could maybe forward me the corrected model at '' it would be of immense help.

Robyn Sir can you please kindly send me Dymanic modelling of Vanadium Redox Flow Battery simulink model with custom library blocks. Sir my mail id is


What sampling frequency would be optimal for capturing transient dynamics of the battery and estimating parameters correctly? I'm trying to use the pulsed discharge method for characterizing a lead-acid battery.

Can you please kindly help me Robyn sir in extending this lithium 2rc model to Vanadium Redox Flow Battery Model

sir can you please kindly extend this lithium model to Vanadium Redox flow battery model and send me to my

mohan kanth


I used parallel computing toolbox for faster parameter estimation,

estimation has stopped and shown the following statement in the SDO tool

'optimization completed because the size of the gradient is less than the selected value of the function tolerance'

How can I solve this?

mohan kanth


I used parallel computational toolbox for faster parameter estimation,

estimation has stopped and shown the following statement in the SDO tool

'optimization completed because the size of the gradient is less than the selected value of the function tolerance'

How can I solve this?

mohan kanth

In parameter estimation , plot- trajectory of parameter estimation have different lines in each parameter, what those lines represents?

mohan kanth

Isaac Thompson

mohan Kanh,
after you open the "parameter estimation gui" you can click "new experiment" and then import data. Double click "Exp" under the experiments box, and you'll see the option to import from an excel file.

still trying to figure out how to use those imported current values in the original model though

mohan kanth

hi Robyn Jackey,

U took 11*1 parameters matrix for discharge pulse

I want to give the input i.e current with charge and discharge pulse with different amplitudes, how I can have the parameters matrix?

Isaac Thompson

Josh Savitz,

I was able to get it working. I missed the "required products" section. you need to have the following installed:
Optimization toolbox
Parallel Computing toolbox
Simulink Design Optimazation (this is the one i was missing, and i ended up buying the student version of matlab and other required products to be able to open buy and use this toolbox)

Josh Savitz

I have the same problem @Isaac Thompson. The orange box to open up the parameter estimation when double clicked returns an error "Undefined function 'speload' for input arguments of type 'char'". Were you able to resolve this issue?

Anibal Morales

babajide owoyele



I'm unable to unzip this file. Has anyone else had this issue?

Isaac Thompson

I was able to install and run the examples, but trying to open the estimation example, double clicking on the orange box, i get the error "speload is not a valid command"
has anyone else ran into this issue?

taha sadeq

Shivaram N V

Hello Robyn,

I made a 2RC model from the 1RC estimation model and then tried estimating the corresponding parameters. But I am getting the following error:

The left hand side is initialized and has an empty range of indices.
However, the right hand side returned one or more results.

Error in sldodialogs.VariableSelectorGC>lcbTableChanged (line 346)
CV{iVar,1} = sVars(ct);

Error in hgfeval (line 62)

Error in javaaddlistener>cbBridge (line 52)
hgfeval(response, java(o), e.JavaEvent)

Error in javaaddlistener>@(o,e)cbBridge(o,e,response) (line 47)
@(o,e) cbBridge(o,e,response));

Could you please let me know why this might be happening?

Shivaram N V

Hello Robyn,

I made a 2RC model from the 1RC estimation model and then tried estimating the corresponding parameters. But I am getting the following error:

The left hand side is initialized and has an empty range of indices.
However, the right hand side returned one or more results.

Error in sldodialogs.VariableSelectorGC>lcbTableChanged (line 346)
CV{iVar,1} = sVars(ct);

Error in hgfeval (line 62)

Error in javaaddlistener>cbBridge (line 52)
hgfeval(response, java(o), e.JavaEvent)

Error in javaaddlistener>@(o,e)cbBridge(o,e,response) (line 47)
@(o,e) cbBridge(o,e,response));

Neeta Khare

Hi Robyn,
Thanks for sharing your work. I would like to add Warburg element into the simscape model. Could you please guide me, how I can add library block in Simscape or if I can add a function block in the circuit.

cris paul

Hello Robyn,thanks for your model and it has really has helped me a lot. Now I want to simulate the Li-ion battery with a 3 R-C branched model and I have watched your video and paper but I'm still not sure how to set up the starting point and end point at every estimation based on Layered Technique. What's more, I want to know how control the initial parameter values at every estimation ? And could you please share your program using 3 R-C branched model? Thank you in advance.

reshma konjari

Yujie Wang

reshma konjari

Hello Robyn,really thanks for your models.
I'm getting this error when I run ssc_lithium_cell_1RC

Failed to find 'C_ext' in library 'LiBatteryElements_lib' referenced by 'ssc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/C1/C_ext'

Can you please help me out with this.

Thank you

Daisy Li

Hi Robyn,thanks for your model!
I'm using Matlab R2014b to run the estimation model but errors as follow occurs:

Error evaluating parameter 'C_Table' in 'ssc_lithium_cell_1RC_estim/Lithium Cell (1RC equivalent circuit model, single temperature)/C_table_1Temp'

Undefined function or variable 'C1'。
Component: Simulink | Category: N.A.

Error evaluating parameter 'SOC_Table' in 'ssc_lithium_cell_1RC_estim/Lithium Cell (1RC equivalent circuit model, single temperature)/C_table_1Temp'

Undefined function or variable 'SOC_LUT'。
Component: Simulink | Category: N.A.

Could you give me advice?

Thank you !


Hi Robyn, thanks for the file.
I want to estimate charge param. I tried use your model but it seems the results is not converged. I replace the PulseData.mat with my own experimental. The experiment is similar with your example, but the current is in charge mode. Could you give me advice? Thank you.

satendra kumar

Dear Robyn, thanks a lot for sharing this. I am working on cell balancing with 4 li-ion cells in series.
I want to start the simulation with different values of soc for all cells. I am using 2rc model.
My doubt is, how can I control the starting point of soc for cells.
Thanks a lot in advance.


For those who have a problem such as:

Failed to generate 'LiBatteryElements_lib'

Caused by:
Error using ne_buildpackage (line 32)
File: C:\<path>\C_table.ssc
Line: 9

Input 'T' declared with unit expression that contains an affine unit: 'C'. Affine units are not allowed when declaring members of this type.

Do the following:
Simscape language doesn't like other units than "Kelvin" for temperature. It needs to be converted by an affine transformation, and sometimes induce error when not used properly.
Change the unit 'C' by 'K', and modify the value for the temperature accordingly in the file "C_table.ssc"

Long Nguyen

Dear Robyn Jackey,
I am working with a team to create a battery management system. I found out your "Lithium Battery Model, Simscape Language and Simulink Design Optimization" some weeks ago and it is very helpful. I want to thank you a lot. However, I have a big question, I tried to use it before and I watched your all videos many times,I saw you did mention about estimate parameters.But I am still not understand at all and I want to ask you how can we use the experiment results and input them in the model?
I watched all videos and I saw that you did not mention how can we input the look-up table into your model. I tried many ways but none of them working.
I am very appreciate your help, please answer me as soon as possible, many thanks.

Kind Regards,
Long Nguyen

Robyn Jackey

@ John Arvanitis - Sorry for the delay. I tested the two model advisor checks in R2015a prerelease, and they worked ok. Were you on a prior release? You can email me from the "Contact Author" page if you like.

mohand hamouda

Dear Mr. Jackey,

I have used their Li-Ion Battery model as part of my Master's thesis, as I have no real battery.
I would like design an MPC controller and an need a lienearized model , but I have to get a problem with linear-battery model. I can not linearize in a battery model an operating point.
can you please tell me to get help for the ÖLinearisierte model?
should I just leave the Battery and control a DC-DC converter Modllieren and then the battery?

I thank you in advance.

Yours sincerely


Thank you very much for these nice examples!

We try to characterize a electronic car battery for appropriate SoC-estimation in the car.
Therefore we measured pulse data and are doing parameter estimation.
Now the question: How do you use the gained data later on in the devices (eg our car)? You normally generate look up tables and implement them in the ECU? Or you bring the complete model to the ECUs? What would be the typical way of proceeding?

Thank you in advance!


Robyn Jackey

Kirankumar - You can use drive cycles (validation) data with Simulink Design Optimization to tune parameters of a model. I would encourage doing so. However, the circuit parameter values may need to have good initial guesses for them to converge.

Pulse data is nice because it allows you to isolate the contributions of the different equivalent circuit elements.


We are trying to estimate parameters for Lithium-Ion battery with Rin+R1||C1 structure. For moment we shall not consider the thermal effect. All three parameters shall be 2-D look-up tables with breakups along SOC and Ibat(temperature in future).

We are looking for high accurate estimation(<10mV). Till now, we used System identification tool box to estimate the parameter for all the scenarios as per the breakups mentioned above. But, while validation with drive pattern data(validation data) we get huge error. We are thinking to try Parameter estimation toolbox to get better results.

My query is:
1) is it possible to directly feed the validation data to parameter identification toolbox for estimation? or its always necessary to provide the pulse data for estimation?
2) Intent is we do not have all the pulse data with different SOC and Ibat.


John Arvanitis

Great Job (Lithium Battery Model, Simscape Language and Simulink Design Optimization)

Now we have an easy way to parameterize battery with accuracy on all conditions.

One question please:
1) During of Model Advisor usage we got
the following error

On Modeling Standards for DO-178C/DO-331 - Check safety-related optimization settings and
On Modeling Standards for DO-178C/DO-331 - Check safety-related code generation settings

Abnormal exit: BLAS loading error: mkl.dll: Not enough storage is available to process this command.

What could I do in order to over come this problem?

Johnny Rico

The downloaded zip archive appears to be damaged. I request the author to kindly re-upload the same.


Ali Rostami

I have troule downloading the file from
the error message is " the site is unavailable or cannot be found.
Has anyone experienced the same or any solution?


Robyn Jackey

I will be presenting during a workshop entitled "Developing Battery Management Systems Using Model-Based Design" at the American Control Conference on June 3rd in Portland, OR. If you are interested in attending, please see:

Robyn Jackey

Lu - can you email me directly through the contact author page?


Hi Robyn, thank you for sharing.

I have a question about the paper"SAE 2013: Simplified Extended Kalman Filter Observer for Battery SOC Estimation

In this paper, you model the hysteresis effect, and use k as the hysteresis factor.
how can I understand the following sentence in Page5"The value of k was obtained by inspection by minimizing the difference between the experimental and simulated VOC vs. SOC curves. VOC(VSOC) is the instantaneous value of the OCV on the minor loop."

what's the experimental VOC(VSOC),is caculted by(VOCch(VSOC)+VOCdisch(VSOC) )/2?
and what's simulated VOC(VSOC), is the difference between measured terminal voltage (Vt) and VRC?

would you please share the progress of k fitting.


Robyn Jackey

Christopher - I have not seen that license error before. Can you please try contacting MathWorks technical support?


I was trying to follow the instructions in the README file, but step 2 is giving me a couple similar errors, for example:
"Error using save_system>i_builtin (line 188)
Cannot save this library because block R_table_1Temp requires a license for , which could not be obtained.
Please try again when a license becomes available."

I am using Matlab R2013A, Simulink 8.1, Optimization Toolbox 6.3, Parallel Computing Toolbox 6.2, and Simscape 3.9. It doesn't look like I Have the Simulink Design Optimization, but I don't think that's what is causing the error that I am seeing. Do you have any suggestions? I looked under the Simulink examples, and I don't see the battery demo even though it is supposed to ship with it.

Thank you!

Robyn Jackey

With R2013a and later, the ssc_lithium_cell_1RC and ssc_lithium_cell_2RC, along with the library LiBatteryElements are now shipping Simscape demos. The shipping versions should be used, because of a Simscape change requiring use of Kelvin rather than Celsius in Simscape language code. The additional demos in this MATLAB Central entry should work, just ensure that the older LiBatteryElements libraries are not added to your MATLAB search path, so it uses the shipping versions.

Maryam Bahramipanah

Thanks Robyn. I did exactly what is written in Readme.text, but by running "ssc_build LiBatteryElements" , I am receiving this error :
Error using LiBatteryElements.C_table (line 9) Input 'T' declared with unit expression that contains an affine unit: 'C'. Affine units are not allowed when declaring members of this type.

:(. I am using the R2012a files.

Robyn Jackey

Hi Maryam,
You might need to add all the directories to your MATLAB search path first. To fix the error you encountered, you might need to rebuild the Simscape library for your platform and MATLAB version. There are directions in the included readme.txt file.

Maryam Bahramipanah

Robyn, I found that I have to run the liBatteryelemets before. SO, I have no problem with that any more. But there is another problem :( . when I started the estimation, I received this message "index exceed matrix dimension". Do you know what is it for?

Maryam Bahramipanah

Hello. First of all thanks for uploading the files.

When I am trying to open each elements of the model (for instance R_table_1Temp), I receive this error:

Error Id: ne_dli: internal: unableToCreatDialog

unable to creat block dialog. If the block belongs to a custom simscape library, please run ssc_build to rebuild the library...."

Can you please help me with that?



Robyn Jackey

For R2012b and later, there are shipping demos of ssc_lithium_cell_1RC and ssc_lithium_cell_2RC models. the LiBatteryElements package is also part of the shipping Simscape demo, so it's not included in the R2012b folder of the zip file.


Isn't there any LiBatteryElements package in the R2012b folder?

Robyn Jackey

Hi Mengjia - Unfortunately the errors you see are expected and the model will not work in R2010a or earlier. The early versions of Simscape lookup tables required all dimensions to be a minimum of size 4, and my demo model only contains 3 temperatures. It will work fine in newer releases, otherwise it might work if you add a fourth temperature to the data for each lookup table.


Hello, I've got errors as below running ssc_lithium_cell_1RC.mdl

1. ssc_lithium_cell_1RC/Solver Configuration: Unable to compile the physical network.

2. sc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/Main Branch Voltage Source (Em)/PS Lookup Table (1D): The size of the vector of input values or output values must be greater than 3.

3. ssc_lithium_cell_1RC/Lithium Cell (1RC equivalent circuit model)/C1/PS Lookup Table (2D): Y-vector must have no less than 4 elements.

And for other 3 lookup tables(2D) I've got the same Y-vector elements issue, so totally 6 errors.

I've followed the 2 steps as readme.txt stated, please kindly advise where go wrong?

PS: I am using the Matlab R2010a to run the files in folder R2010b.

Robyn Jackey

To answer your questions:

1. In the paper, we chose the initial conditions based on the driving cycle we used for validation. The temperature T=20 was based on a measured cell temperature (approximately same as electrolyte). Initial SOC was selected based on best fit of the measured vs simulated voltage at the very beginning part of the drive cycle.

2. You can modify the InputData*.xls files and import them into the Signal Builder block if you like to change the input curves. However, you will need to delete the "Copyright ..." string that was placed in cell E1 to avoid an error. Otherwise, Signal Builder tries to import data from column E, causing the error you found.

dang hong

Dear Sir,
In reference paper " high fidelity electrical model with model with thermal dependence for characterization and simulation of high power lithium battery cells", how to choose initial SOC = 45 %,T =20, ? For example, in the case of using ssc_lithium_cell_1RC.mdl.
when importing "InputData_1RC.xls" in signal builder of ssc_lithium_cell_1RC, there is a error " attempted to access td(:,3); index out of bounds because size(td)=[46,2]. How to import that file?

Robyn Jackey

The R2012a folder contains files that use newer features that will only work on R2012a or later. I suspect that is the reason for the build error. The R2010b model should work in that version and up, however it is a little less tidy because the lookup tables were external to the custom Simscape language blocks.


run ssc_build LiBatteryElements

the following errors apeared.

Generating 'LiBatteryElements_lib.mdl' in the current directory 'C:\Documents and Settings\Jiucai\My Documents\Downloads\ssc_Li_cell_20120419\ssc_Li_cell_20120419\R2012a' ...
Failed to generate 'LiBatteryElements_lib'

Caused by:
Error using ne_buildpackage (line 32)
File: C:\Documents and Settings\Jiucai\My
Line: 13
Attribute Size is not supported for constructs of type

MATLAB Release Compatibility
Created with R2019b
Compatible with R2019a 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!