Documentation Center

  • Trial Software
  • Product Updates


Compare toolbox version to specified version string


verLessThan(toolbox, version)


verLessThan(toolbox, version) returns logical 1 (true) if the version of the toolbox specified by the string toolbox is older than the version specified by the string version, and logical 0 (false) otherwise. Use this function when you want to write code that can run across multiple versions of the MATLAB® software, when there are differences in the behavior of the code in the different versions.

The toolbox argument is a string enclosed within single quotation marks that contains the name of a MATLAB toolbox folder. The version argument is a string enclosed within single quotation marks that contains the version to compare against. This argument must be in the form major[.minor[.revision]], such as 7, 7.1, or 7.0.1. If toolbox does not exist, MATLAB generates an error.

To specify toolbox, find the folder that holds the Contents.m file for the toolbox and use that folder name. To see a list of all toolbox folder names, enter the following statement in the MATLAB Command Window:

dir([matlabroot '/toolbox'])


These examples illustrate usage of the verLessThan function.

Example 1 – Checking For the Minimum Required Version

if verLessThan('simulink', '4.0')
    error('Simulink 4.0 or higher is required.');

Example 2 – Choosing Which Code to Run

if verLessThan('matlab', '7.0.1')
% -- Put code to run under MATLAB 7.0.0 and earlier here --
% -- Put code to run under MATLAB 7.0.1 and later here --

Example 3 – Looking Up the Folder Name

Find the name of the Data Acquisition Toolbox™ folder:

dir([matlabroot '/toolbox/d*'])

   daq        database   des      distcomp   dotnetbuilder
   dastudio   datafeed   dials    dml        dspblks

Use the toolbox folder name, daq, to compare the Data Acquisition Toolbox software version that MATLAB is currently running against version number 3:

verLessThan('daq', '3')
ans =

See Also

| | | | | |

Was this topic helpful?