Main Content


Create custom units database file from Microsoft Excel spreadsheet



createCustomDBFromExcel(units_db.xlsx) creates a custom units database file from an Excel® spreadsheet that contains custom units. On all supported platforms, the createCustomDBFromExcel function supports: .xls and .xlsx files.

To see the supported spreadsheet format, see Custom Units Spreadsheet Format.


collapse all

Create a custom units database file from custom Excel spreadsheet file, unitsDB.xlsx.

Create a Excel spreadsheet containing these columns and data in any order:

  • name, containing ounce_force

  • symbol, containing ozf

  • asciiSymbol, containing ozf

  • displayName, containing {\rm{}oz_{force}}

  • definitionExpression, containing oz*gn

  • conversionFactor, containing 1

  • conversionOffset, containing 0

  • physicalQuantity, containing force

Enter your custom unit specifications.

Save the database file, for example unitsDB.xlsx.

Create the database.


The function creates unitsDB.slunitdb.mldatx in the current folder.

Add the current folder to the MATLAB® path.

addpath C:\work\custom_units

Load the new units database into memory.


Input Arguments

collapse all

Custom unit database, specified as the file name of an Excel units database file. Create this file as an Excel spreadsheet with columns that contain custom unit information.

The function creates a unit database file, units_db.slunitdb.mldatx, in the current folder, where units_db is the name of the Excel file. If the unit entry is empty for the symbol, asciiSymbol, or displayName columns, the function uses the unit name for the missing symbol, asciiSymbol, or displayName entries.

To see the supported spreadsheet format, see Custom Units Spreadsheet Format.

Example: custom_units.xlsx

Data Types: char | string

Introduced in R2020a