Main Content

createCustomDBFromExcel

Create custom units database file fromMicrosoftExcelspreadsheet

Description

example

createCustomDBFromExcel(units_db.xlsx)creates a custom units database file from an Excel®spreadsheet that contains custom units. On all supported platforms, thecreateCustomDBFromExcelfunction supports:.xlsand.xlsxfiles.

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

Examples

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, containingounce_force

  • symbol, containingozf

  • asciiSymbol, containingozf

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

  • definitionExpression, containingoz*gn

  • conversionFactor, containing1

  • conversionOffset, containing0

  • physicalQuantity, containingforce

Enter your custom unit specifications.

Save the database file, for exampleunitsDB.xlsx.

Create the database.

createCustomDBFromExcel('unitsDB.xlsx')

The function createsunitsDB.slunitdb.mldatxin the current folder.

Add the current folder to the MATLAB®path.

addpathC:\work\custom_units

Load the new units database into memory.

rehashUnitDBs

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, whereunits_dbis the name of the Excel file. If the unit entry is empty for thesymbol,asciiSymbol, ordisplayNamecolumns, the function uses the unit name for the missingsymbol,asciiSymbol, ordisplayNameentries.

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

Example:custom_units.xlsx

Data Types:char|string

Introduced in R2020a