Main Content

matlab.mpm.Version

Package version

Since R2024b

    Description

    A matlab.mpm.Version object stores package version information. You can use a version object to limit searches for packages using mpmsearch.

    Creation

    Description

    pkgver = matlab.mpm.Version(major,minor,patchnum) creates a package version object where each input corresponds to an element of semantic version syntax.

    example

    pkgver = matlab.mpm.Version(versionstr) creates a package version object corresponding to the specified string. versionstr must follow semantic version syntax.

    example

    pkgver = matlab.mpm.Version(___,Prerelease=prver) creates a package version object with the specified prerelease version.

    example

    pkgver = matlab.mpm.Version(___,Prerelease=prver,Build=buildver) creates a package version object with the specified build version.

    example

    Input Arguments

    expand all

    Major version, specified as a nonnegative integer scalar.

    This argument sets the Major property.

    Minor version, specified as a nonnegative integer scalar.

    This argument sets the Minor property.

    Patch version, specified as a nonnegative integer scalar.

    This argument sets the Patch property.

    Pre-release version, specified as a string row vector.

    This argument sets the Prerelease property.

    Example: "alpha"

    Example: ["alpha" "1"]

    Build version, specified as a string row vector.

    This argument sets the Build property.

    Example: "exp"

    Example: ["exp" "sha" "4225k32"]

    Version string, specified as a string scalar containing a semantic version.

    Based on the format of the string, this argument sets properties of the package version object.

    Example: "1.2.3"

    Example: "1.2.3-alpha"

    Example: "1.2.3-alpha+exp"

    Properties

    expand all

    Major version, specified as a double scalar.

    Minor version, specified as a double scalar.

    Patch version, specified as a double scalar.

    Pre-release version, specified as a string row vector.

    Build version, specified as a string row vector.

    Examples

    collapse all

    Create a package version object.

    pkgver = matlab.mpm.Version(1,2,3)
    pkgver = 
    
      Version with properties:
    
             Major: 1
             Minor: 2
             Patch: 3
        Prerelease: [1×0 string]
             Build: [1×0 string]

    Create a package version object using a string input.

    pkgver = matlab.mpm.Version("1.2.3-alpha+exp")
    pkgver = 
    
      Version with properties:
    
             Major: 1
             Minor: 2
             Patch: 3
        Prerelease: "alpha"
             Build: "exp"

    Create a package version object.

    pkgver = matlab.mpm.Version(1,2,3,Prerelease="alpha")
    pkgver = 
    
      Version with properties:
    
             Major: 1
             Minor: 2
             Patch: 3
        Prerelease: "alpha"
             Build: [1×0 string]

    Create a package version object.

    pkgver = matlab.mpm.Version(1,2,3,Prerelease="alpha",Build="exp")
    pkgver = 
    
      Version with properties:
    
             Major: 1
             Minor: 2
             Patch: 3
        Prerelease: "alpha"
             Build: "exp"

    More About

    expand all

    Tips

    • Equality between mpm.matlab.Version objects follows Semantic Versioning 2.0.0 standards and ignores the Build property. For example, compare two version objects with different Build values:

      v1 = matlab.mpm.Version(1,2,3,Build="a");
      v2 = matlab.mpm.Version(1,2,3,Build="b");
      v1 == v2
      ans =
      
        logical
      
         1

    Version History

    Introduced in R2024b