Contenuto principale

saveToJson

R2026b

Save Topology object to JSON file

Since R2026b

Description

saveToJson(customTopology,filename) saves the Topology object, customTopology, in the specified JSON file, filename. The filename argument is a character vector or string scalar that specifies the name of the output file with the .json extension.

example

Examples

collapse all

Create a custom topology.

import simscape.battery.builder.*;

myCell = batteryCell(batteryPouchGeometry);
customTopology = simscape.battery.builder.Topology(...
    Name="PouchLayout", ...
    NumParallelCells=4, ...
    NumSeriesAssemblies=1, ...
    BatteryCell=myCell);

Save the topology to a JSON file.

saveToJson(customTopology,"pouchLayout.json")

Open the JSON file you created. The JSON file stores the topology name, stacking axis, cell geometry type and dimensions, cell center positions, number of parallel cells, number of series assemblies, and axis limits.

edit("pouchLayout.json")
{"Name":"PouchLayout","StackingAxis":"Y","CellGeometry":"simscape.battery.builder.PouchGeometry","CellCenterPositions":[{"X":null,"Y":null,"CellID":1,"ParallelAssemblyID":1},{"X":null,"Y":null,"CellID":2,"ParallelAssemblyID":1},{"X":null,"Y":null,"CellID":3,"ParallelAssemblyID":1},{"X":null,"Y":null,"CellID":4,"ParallelAssemblyID":1}],"NumParallelCells":4,"NumSeriesAssemblies":1,"XAxisLimit":0.5,"YAxisLimit":0.5,"Length":0.23,"Thickness":0.01,"TabLocation":"Standard","TabWidth":0.04,"TabHeight":0.03,"Height":0.28}

Input Arguments

collapse all

Custom topology to save, specified as a Topology object.

Name of the output JSON file where the function stores the Topology object, specified as a character vector or string scalar.

Version History

Introduced in R2026b