File Exchange

image thumbnail


version 1.0.9 (6.3 KB) by Raphael Guzman
Semantic version comparison m-function. Matlab function that will compare a cell array of values to a reference version (default: greater th


Updated 13 Oct 2020

From GitHub

View Version History

View license on GitHub

compareVersions - Semantic version comparison (default: greater than or equal)

This function compares an array of semantic versions against a reference version.


res = COMPAREVERSIONS(verArray, verComp, verCheck)
verArray: Cell array with the following conditions:
- be of length >= 1,
- contain only string elements, and
- each element must be of length >= 1.
verComp: String or Char array that verArray will compare against for
greater than evaluation. Must be:
- be of length >= 1, and
- a string.
verCheck: (Optional) Function handle for comparison with the following conditions:
- Must be of the form @(x,y)
- In an element of verArray, x represents a float for the part to compare
- In verComp, y represents a float for the part to compare
- Default is greater than or equal to i.e. @(x,y) x >= y
res: Logical array that identifies if each cell element in verArray
satisfies verCheck.
Tests included for reference. From root package directory,
use commands:
suite = TestSuite.fromFolder(pwd, 'IncludingSubfolders', true);

output = compareVersions({'3.2.4beta','','8.0'}, '8.0.0'); %logical([0 1 1])
output = compareVersions({'3.2.4beta','','8.0'}, '8.0.0', @(x,y) x<y); %logical([1 0 0])
compareVersion_v = compareVersions('version'); %'1.0.9'

Tested: Matlab (R2016b) Linux
Author: Raphael Guzman, DataJoint

$License: MIT (use/copy/change/redistribute on own risk) $
$File: compareVersions.m $
001: 2019-06-12 11:00, First version.

- None

Cite As

Raphael Guzman (2021). compareVersions (, GitHub. Retrieved .

Comments and Ratings (1)

Raphael Guzman

Hello this is a test comment.

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!