Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

verLessThan

Compare toolbox version to specified character vector

Syntax

  • tf = verLessThan(toolbox,version)
    example

Description

example

tf = verLessThan(toolbox,version) returns logical 1 (true) if the version of the toolbox is older than the value specified by version. Otherwise, it returns logical 0 (false). Use this function to write code that runs on multiple versions of MATLAB®, when there are differences in the behavior of the code in the different versions.

Examples

collapse all

Modify code that runs in MATLAB R2014a, but that generates an error in R2014b or later.

Create two surface plots. The default color palates are different depending on which version of MATLAB you are using.

s1 = surface(magic(5));
s2 = surface(magic(5)*10,'FaceColor','yellow');

Modify surface s2 by the color of the surface underneath. Starting in R2014b, the EraseMode property has been removed from all graphics objects. Replace the EraseMode property with a value of the FaceAlpha property for code running in MATLAB R2014b and later.

if verLessThan('matlab','8.4')
    % -- Code to run in MATLAB R2014a and earlier here --
    s2.EraseMode = 'xor';
else
    % -- Code to run in MATLAB R2014b and later here --
    s2.FaceAlpha = .25;
end

Compare the Simulink® version that is running against version 4.0. If the version is earlier than 4.0, display an error message because the feature is not supported.

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

Compare the Data Acquisition Toolbox™ version that MATLAB is running.

Find the name of the toolbox folder. Your output depends on the toolboxes installed on your system.

dir([matlabroot '/toolbox/d*'])
   daq        database   des      distcomp   dotnetbuilder
   dastudio   datafeed   dials    dml        dspblks

Use the toolbox folder name, daq.

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

     0

MATLAB is running Data Acquisition Toolbox version 3 or later.

Input Arguments

collapse all

Name of MATLAB toolbox folder, specified as a character vector. To specify toolbox, find the folder containing the Contents.m file for the toolbox and use that folder name. To see a list of all toolbox folder names, type:

dir([matlabroot '/toolbox'])

If toolbox does not exist, MATLAB displays an error.

Example: 'images'

Version number of the program or toolbox to compare against, specified as a character vector. Specify the version number in the form of major[.minor[.revision]].

Example: '9.2'

See Also

| | | | | |

Introduced in R2007a

Was this topic helpful?