Read_BMJN_Meta
Read BMJN JSON file and return Meta information as MATLAB structured variable.
This function reads a BMJN_
Syntax
metaStruct = Read_BMJN_Meta('bmjn', bmjn)
metaStruct = Read_BMJN_Meta('filePath', filePath)
metaStruct = Read_BMJN_Meta('bmjn', bmjn, 'pathToBMParameters', pathToBMParameters)
metaStruct = Read_BMJN_Meta('filePath', filePath, 'pathToBMParameters', pathToBMParameters)
Optional Name-Value Arguments
| Name | Type | Default | Description |
|---|---|---|---|
bmjn |
double |
[] (empty) |
Breathe Model JSON Number to read. If provided, the function will look for BMJN_ |
filePath |
string |
[] (empty) |
Direct path to the JSON file to read. If provided, this takes precedence over bmjn. Must provide either bmjn or filePath |
pathToBMParameters |
string |
"BM_Parameters" | Path to the Breathe Model parameters directory |
Output
Returns a MATLAB structured variable (metaStruct) containing only the Meta information from the JSON file. The structure includes metadata fields such as:
| Field | Type | Description |
|---|---|---|
cellName |
string |
Name of the cell |
areaCell_m2 |
double |
Cell area in square meters |
massCell_kg |
double |
Cell mass in kilograms |
nominalCap_Ah |
double |
Nominal capacity in Ampere-hours |
modelVersion |
string |
Model version string |
description |
string |
Design description information |
| Additional metadata fields | varies |
Additional metadata fields as present in the JSON file |
Error Handling
- If neither
bmjnnorfilePathis provided, displays error message - If parameter directory is not found, displays error message
- If JSON file cannot be read or parsed, displays error message
- If JSON file does not exist, displays error message
- If Meta field is missing from JSON file, displays error message
Examples
Read BMJN File by Number Using Default Parameter Directory
% Read metadata from BMJN_1000.json in the default BM_Parameters folder
metaData = Read_BMJN_Meta('bmjn', 1000);
Read BMJN File by Number Using Custom Parameter Directory
% Read metadata from BMJN_0.json in a custom parameter directory
metaData = Read_BMJN_Meta('bmjn', 1000, 'pathToBMParameters', 'Custom_Path');
Read JSON File by Direct File Path
% Read metadata from a JSON file using direct file path
metaData = Read_BMJN_Meta('filePath', 'BM_Parameters/BMJN_1000.json');
Access Metadata Fields from Returned Structure
% Read metadata and access individual fields
metaData = Read_BMJN_Meta('bmjn', 1000);
cellName = metaData.cellName;
cellArea = metaData.areaCell_m2;
cellMass = metaData.massCell_kg;
nominalCapacity = metaData.nominalCap_Ah;
modelVersion = metaData.modelVersion;
description = metaData.description;
Use File Path with Custom Parameter Directory
% Read metadata using file path with custom parameter directory
metaData = Read_BMJN_Meta('filePath', 'BMJN_1000.json', 'pathToBMParameters', 'Custom_Path');
Notes
- The function extracts only the
Metafield from the JSON file, not the full parameter set - If
filePathis provided, it takes precedence overbmjn - The function validates that either
bmjnorfilePathis provided - Relative file paths are resolved relative to the parameter directory when using
filePath - BM_Parameters is added to the MATLAB path when Breathe Model is installed