ifversion

버전 1.2.1.2 (9.06 KB) 작성자: Rik
Determine if the current version satisfies a version restriction
다운로드 수: 41
업데이트 날짜: 2024/3/23

ifversion documentation

View ifversion on File Exchange Open in MATLAB Online

Table of contents

Description

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 23.2). That also includes the potential for float rounding errors.

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.

Matlab/Octave

Syntax

tf=ifversion(test,Rxxxxab)
tf=ifversion(test,Rxxxxab,'Octave',test_for_Octave,v_Octave)

Output arguments

Argument Description
tf If the current version satisfies the test this returns true.
This works similar to verLessThan.

Input arguments

Argument Description
test Char array containing a logical test. The interpretation of this is equivalent to eval([current test Rxxxxab]). For examples, see below.
Rxxxxab Char array containing a release description (e.g. 'R13', 'R14SP2' or 'R2019a') or the numeric version. Note that 9.10 is interpreted as 9.1 when using numeric input.
test_for_Octave See the test parameter. If not provided, the same test will run on GNU Octave as on Matlab. This will also trigger a warning.
v_Octave The numeric version of Octave. If not provided, the same test will run on GNU Octave as on Matlab. This will also trigger a warning.

Examples

A few examples of valid syntax options:

    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('==',24.01)           % returns true only when run on R2024a
    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) !!!

Compatibility, version info, and licence

Compatibility considerations:

  • This is expected to work on all releases.
Test suite result Windows Linux MacOS
Matlab R2024a W11 : Pass Monterey : Pass
Matlab R2023b ubuntu_22.04 : Pass Monterey : Pass
Matlab R2023a W11 : Pass
Matlab R2022b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2022a W11 : Pass
Matlab R2021b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2021a W11 : Pass
Matlab R2020b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2020a W11 : Pass
Matlab R2019b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2019a W11 : Pass
Matlab R2018b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2018a W11 : Pass
Matlab R2017b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2016b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2015a W11 : Pass
Matlab R2013b W11 : Pass
Matlab R2007b W11 : Pass
Matlab 6.5 (R13) W11 : Pass
Octave 8.4.0 W11 : Pass
Octave 8.2.0 W11 : Pass
Octave 7.2.0 W11 : Pass
Octave 6.2.0 W11 : Pass ubuntu_22.04 : Pass Catalina : Pass
Octave 5.2.0 W11 : Pass
Octave 4.4.1 W11 : Pass Catalina : Pass
Version: 1.2.1.2
Date:    2024-03-23
Author:  H.J. Wisselink
Licence: CC by-nc-sa 4.0 ( https://creativecommons.org/licenses/by-nc-sa/4.0 )
Email = 'h_j_wisselink*alumnus_utwente_nl';
Real_email = regexprep(Email,{'*','_'},{'@','.'})

Test suite

The tester is included so you can test if your own modifications would introduce any bugs. These tests form the basis for the compatibility table above. Note that functions may be different between the tester version and the normal function. Make sure to apply any modifications to both.

인용 양식

Rik (2024). ifversion (https://github.com/thrynae/ifversion/releases/tag/v1.2.1.2), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2024a
R13SP1 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기
태그 태그 추가

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.2.1.2

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

1.2.1.1

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

1.2.1.0

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

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

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.