Main Content

sbiounit

Create user-defined unit

You can no longer specify an offset as an input when you call sbiounit. Use an absolute unit that does not require an offset. For details, see Compatibility Considerations.

Syntax

unitObject = sbiounit('NameValue')
unitObject = sbiounit('NameValue', 'CompositionValue')
unitObject = sbiounit('NameValue','CompositionValue',MultiplierValue)
unitObject = sbiounit('NameValue','CompositionValue',...'PropertyName', PropertyValue...)

Arguments

NameValue

Name of the user-defined unit. NameValue must begin with characters and can contain characters, underscores, or numbers. NameValue can be any valid MATLAB® variable name.

CompositionValue

Shows the combination of base and derived units that defines the unit NameValue. For example molarity is mole/liter. Base units are the set of units used to define all unit quantity equations. Derived units are defined using base units or mixtures of base and derived units.

MultiplierValue

Numerical value that defines the relationship between the user-defined unit NameValue and the base unit as a product of the MultiplierValue and the base unit. For example, 1 mole is 6.0221e23*molecule. The MultiplierValue is 6.0221e23.

PropertyName

Name of the unit object property, for example,'Notes'.

PropertyValue

Value of the unit object property, for example, 'New unit for GPCR model'.

Description

unitObject = sbiounit('NameValue') constructs a SimBiology® unit object named NameValue. Valid names must begin with a letter, and be followed by letters, underscores, or numbers.

unitObject = sbiounit('NameValue', 'CompositionValue') allows you to specify the name and the composition of the unit.

unitObject = sbiounit('NameValue','CompositionValue',MultiplierValue) creates a unit with the name NameValue where the unit is defined as MultiplierValue*CompositionValue.

unitObject = sbiounit('NameValue','CompositionValue',...'PropertyName', PropertyValue...) defines optional properties. The name-value pairs can be in any format supported by the function set.

In order to use unitObject, you must add it to the user-defined library with the sbioaddtolibrary function. To get the unit object into the user-defined library, use the following command:

sbioaddtolibrary(unitObject);
You can view additional unitObject properties with the get command. You can modify additional properties with the set command. For more information about unit object properties and methods, see Unit object.

Use the sbiowhos function to list the units available in the user-defined library.

Examples

This example shows you how to create a user-defined unit, add it to the user-defined library, and query the library.

  1. Create units for the rate constants of a first-order and a second-order reaction.

    unitObj1 = sbiounit('firstconstant', '1/second', 1);
    unitObj2 = sbiounit('secondconstant', '1/molarity*second', 1); 
  2. Add the unit to the user-defined library.

    sbioaddtolibrary(unitObj1);
    sbioaddtolibrary(unitObj2);
    

  3. Query the user-defined library in the root object.

    rootObj = sbioroot;
    rootObj.UserDefinedLibrary.Units
    
    ans = 
    
       SimBiology Unit Array
    
       Index:    Library:       Name:             Composition:         Multiplier:
       1         UserDefined    firstconstant     1/second             1          
       2         UserDefined    secondconstant    1/molarity*second    1          

    Alternatively, use the sbiowhos command.

    sbiowhos -userdefined -unit
    
       SimBiology UserDefined Units
                                       
       Index:  Name:           Composition:             Multiplier:     
       1       firstconstant   1/second                 1.000000        
       2       secondconstant  1/molarity*second        1.000000   

Version History

Introduced in R2008a

expand all