Characterize Battery Equivalent Circuit Block (Code)
Using the characterizeBattery method, characterize the Battery Equivalent Circuit (Simscape Battery) block and evaluate a feature using a data set.
Create mbcrunner Object
Create a handle to a CAGE project.
r = mbcrunner;
Open Simulink Model
Open the Simulink model containing the Battery Equivalent Circuit block.
open("Simscape_BEC.slx");Set the batteryBlock variable to the battery block path.
batteryBlock = "Simscape_BEC/Battery Equivalent Circuit";Characterize Battery Cell
Characterize the battery using the data files located in the folder HPPC_data/origPreprocessedData. Set the number of iterations for the battery characterization process to 25.
[tbls,sfit] = characterizeBattery( ... r,batteryBlock,fullfile(pwd,'HPPC_data','origPreprocessedData'), ... NumIterations=25,ShowProgress=false);
Preview the open circuit voltage table.
surf(SOC_vec,Temperature_vec,tbls.OCV'); xlabel('SOC');ylabel('Temperature');zlabel('OCV Table');

Evaluate Feature
Evaluate the Voltage3 feature using the hppcDataBAKcell0degC.mat data file.
[results,s] = evaluateFeature(r,"Voltage3", ... fullfile( ... pwd,'HPPC_data', 'origPreprocessedData','hppcDataBAKcell0degC.mat'));
Plot the voltage error to inspect the fit.
plot(results.voltage - results.Voltage3, '.'); ylabel('Error'); title(sprintf('Difference Between measured voltage and Voltage3 (RMSE: %.4f)', s));
