verLessThan - Compare toolbox version to specified character vector - MATLAB (original) (raw)

Main Content

Compare toolbox version to specified character vector

Syntax

Description

tf = verLessThan([toolbox](#butbf7o-1-toolbox),[version](#butbf7o-1-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®.

Using verLessThan to determine if the current MATLAB release is older than a specified release is not recommended. UseisMATLABReleaseOlderThan instead.

example

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.

MATLAB is running Data Acquisition Toolbox Version 3 or later.

Input Arguments

collapse all

Version 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'

Extended Capabilities

expand all

Usage notes and limitations:

Version History

Introduced in R2007a

expand all

Using verLessThan to determine if the current MATLAB release is older than a specified release is not recommended. UseisMATLABReleaseOlderThan instead.