ifversion

Version 1.2.0.0 (13.1 KB) by Rik
Determine if the current version satisfies a version restriction

34 Downloads

Updated 6 Apr 2023

From GitHub

View License on GitHub

View ifversion on File Exchange

This minitool helps you determine the version of Matlab (or Octave) that is running your code. This is helpful when imposing a minimum version requirement, or when different versions need different methods to reach the same end result. By using persistent variables this will stay fast even with repeated calls.

You shouldn't use a logical test with v=version;v=str2double(v(1:3)); as it is incomplete for several releases (like e.g. 7.14 or a future version 10.1). That also includes the potential for float rounding errors.

% examples:
ifversion('>=','R2009a')        % returns true when run on R2009a or later
ifversion('<','R2016a')         % returns true when run on R2015b or older
ifversion('==','R2018a')        % returns true only when run on R2018a
ifversion('==',9.14)            % returns true only when run on R2023a
ifversion('<',0,'Octave','>',0) % returns true only on Octave
ifversion('<',0,'Octave','>=',6)% returns true only on Octave 6 and higher
ifversion('==',9.10)            % !!! returns true only when run on R2016b (v9.1), not R2021a (v9.10) !!!

If you don't want to use a separate function, there are two built-in functions that may do what you need: verLessThan (introduced in R2007a) and isMATLABReleaseOlderThan (introduced in R2020b). The latter also allows filtering based on release type (pre-release vs normal release) and update number.

Licence: CC by-nc-sa 4.0

Cite As

Rik (2023). ifversion (https://github.com/thrynae/ifversion/releases/tag/v1.2.0), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2023a
Compatible with R13SP1 and later releases
Platform Compatibility
Windows macOS Linux
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and MATLAB Answers
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

See release notes for this release on GitHub: https://github.com/thrynae/ifversion/releases/tag/v1.2.0

1.1.2

See release notes for this release on GitHub: https://github.com/thrynae/ifversion/releases/tag/v1.1.2

1.1.1

See release notes for this release on GitHub: https://github.com/thrynae/ifversion/releases/tag/v1.1.1

1.1.0

See release notes for this release on GitHub: https://github.com/thrynae/ifversion/releases/tag/v1.1.0

1.0.6

See release notes for this release on GitHub: https://github.com/thrynae/ifversion/releases/tag/v1.0.6

1.0.5

See release notes for this release on GitHub: https://github.com/thrynae/ifversion/releases/tag/v1.0.5

1.0.4

See release notes for this release on GitHub: https://github.com/thrynae/ifversion/releases/tag/v1.0.4

1.0.3

See release notes for this release on GitHub: https://github.com/thrynae/ifversion/releases/tag/1.0.3

1.0.2

added 2019b and 2020a, edited syntax, expanded test

1.0.1

more fleshed-out implementation, replacing getversion by ifversion

1.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.