Main Content


Create pack of module assemblies

Since R2024a


Use the batteryPack function to create a battery pack object that represents a number of ModuleAssembly objects connected electrically in series or in parallel. For more information about the Pack object and its properties, see Pack (object).

pack = batteryPack creates a battery pack that comprises module assemblies with default property values.


pack = batteryPack(ModuleAssembly) sets the ModuleAssembly property to create a battery pack that comprises one module assembly.

pack = batteryPack(___,Name=Value) specifies the pack properties using one or more name-value arguments. Specify the name-value arguments after all the arguments in any of the previous syntaxes. For a list of properties, see the Properties section of the Pack object.

For example, create a pack with four default module assemblies connected in series, stacked along the x-axis, and with a gap between the module assemblies equal to 0.005 m.

pack = batteryPack(...
    repmat(batteryModuleAssembly,1,4), ...

You can define the number and types of module assemblies in the ModuleAssembly property. If your pack comprises many module assemblies with exactly the same property values, you can use the repmat function to specify the ModuleAssembly property. Otherwise, specify an array of distinct module assemblies.


collapse all

Create a Cell object with a cylindrical geometry.

cell = batteryCell(batteryCylindricalGeometry)

Create a ParallelAssembly object of three parallel cells with the default topology.

pSet = batteryParallelAssembly(cell,3)

Use this ParallelAssembly object to create a Module object of 10 parallel assemblies connected in series and stack them along the x-axis.

module = batteryModule(pSet,10,StackingAxis="X")

Use the Module object to create a ModuleAssembly object of four identical modules connected in series.

moduleassembly = batteryModuleAssembly(repmat(module,1,4))

Use the ModuleAssembly object to create a Pack object of two identical module assemblies connected in series.

pack = batteryPack(repmat(moduleassembly,1,2))

Visualize the pack by using a BatteryChart object.

packChart = batteryChart(pack);

To define the cell balancing strategy for a pack, follow the steps in Create Cylindrical Cell Pack with Two Series Module Assemblies to create a pack.

Set a common cell balancing strategy.

pack.BalancingStrategy = "Passive"

To maintain consistency between the BalancingStrategy properties of the pack and all of its underlying components, setting the pack balancing strategy automatically modifies all the BalancingStrategy property in each of the underlying module components of the pack.


Input Arguments

collapse all

Set of battery module assemblies in the battery pack, specified as a ModuleAssembly object or an array of ModuleAssembly objects. The Pack object electrically connects the module assemblies in series or in parallel according to the CircuitConnection property. If your pack comprises many module assemblies with the same property values, you can use the repmat function to specify this property. Otherwise, specify an array of distinct module assemblies.


This property does not affect how the Pack object stacks the modules. Only the StackingAxis property defines the stacking strategy.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: batteryPack(InterModuleAssemblyGap=simscape.Value(0.05,"m"))


The properties listed here are only a subset. For a complete list, see the Properties section of the Pack object.

Shortest distance between module assemblies inside the battery pack, specified as a positive scalar or a simscape.Value object that represents a positive scalar with a unit of length. The value of this property must be less than 0.1 m.

If you set this property directly with a positive scalar value instead of using a simscape.Value object, this object converts the value to a simscape.Value object with meter as its physical unit.

State-of-charge cell balancing strategy for the pack, specified as "None", "Passive", or "External".

To specify and model an external cell balancing strategy, set this property to "External". The Pack (Generated Block) then exposes two electrical array-of-nodes ports, +BUS and -BUS. For desktop simulations and hardware-in-the-loop battery emulation hardware, use this option in conjunction with the Passive Balancing Interface block.


Setting this property automatically propagates its value to all the subcomponent battery objects inside this batteryPack object. However, this change does not propagate to the other battery objects in your MATLAB workspace. If you do not set this property when you create this batteryPack object, then the default value is automatically propagated to all its subcomponent battery objects.

Version History

Introduced in R2024a