image thumbnail

ifversion

version 1.1.0 (9.8 KB) by Rik
Determine if the current version satisfies a version restriction

23 Downloads

Updated 26 Sep 2021

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.9)             % returns true only when run on R2020b
ifversion('<',0,'Octave','>',0) % returns true only on Octave
ifversion('<',0,'Octave','>=',6)% returns true only on Octave 6 and higher

Licence: CC by-nc-sa 4.0

Cite As

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

MATLAB Release Compatibility
Created with R2021b
Compatible with R13SP1 and later releases
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Acknowledgements

Inspired: Image Manipulation Toolbox

Community Treasure Hunt

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

Start Hunting!
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.