Main Content

verLessThan

(Not recommended) Compare toolbox version to specified character vector

Using verlessthan determine if current MATLAB® release is older than a specified release is not recommended. Use isMATLABReleaseOlderThan instead.

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). When there are differences in the behavior of the code in the different versions, use this function to write code that runs on multiple versions of MATLAB.

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 palettes 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            datafeed       dig            dnnfpga        driving        
database       diagram        dmr            dotnetbuilder  dsp 

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'

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced in R2007a

expand all