Main Content

verLessThan

Compare toolbox version to specified character vector

Description

example

tf = verLessThan(toolbox,version)returns logical 1 (true) if the version of the toolbox is older than the value specified byversion. 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 surfaces2by the color of the surface underneath. Starting in R2014b, theEraseModeproperty has been removed from all graphics objects. Replace theEraseModeproperty with a value of theFaceAlphaproperty for code running in MATLAB R2014b and later.

ifverLessThan('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.

ifverLessThan('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 specifytoolbox, find the folder containing theContents.mfile for the toolbox and use that folder name. To see a list of all toolbox folder names, type:

dir([matlabroot'/toolbox'])

Iftoolboxdoes not exist, MATLAB displays an error.

Example:'images'

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

Example:'9.2'

Introduced in R2007a