Compare Matlab version to specified number
In opposite to other similar functions in the FEX, this function is not confused by the version numbers 7.10 (2010a) and 7.1 (R14SP3). Also failing:
sscanf(version, '%f', 1) <= 7.8
and VERLESSTHAN published by Matlab:
This C-Mex function takes about 0.6% of the processing time needed by Matlab's VERLESSTHAN('matlab'), so it can be used in repeatedly called functions without wasting too much time.
Match = isMatlabVer(Relop, N)
Relop: Comparison operator as string: '<', '<=', '>', '>=', '=='.
N: Number to compare with as DOUBLE vector with 1 to 4 elements.
Match: TRUE if matching, FALSE otherwise.
version '188.8.131.522 (R2009a)' (different results for other version!)
isMatlabVer('<=', 7) % TRUE
isMatlabVer('>', 6) % TRUE
isMatlabVer('<', [7, 8]) % FALSE
isMatlabVer('<=', [7, 8]) % TRUE
isMatlabVer('>', [7, 8, 0, 342]) % FALSE
isMatlabVer('==', 7) % TRUE
isMatlabVer('==', [7, 10]) % FALSE
isMatlabVer('>', [7, 8, 0]) % FALSE (the 342 is not considered!)
version '184.108.40.206 (2010a)':
isMatlabVer('>', [7, 2]) % TRUE
Pre-compiled files: http://www.n-simon.de/mex
Tested: Matlab 6.5, 7.7, 7.8, WinXP 32 bit, compatibility to Linux, Mac, 64 bit is assumed.
Compiler: BCC 5.5, LCC 2.4/3.8, Open Watcom 1.8, MSVC 2008
I'd appreciate suggestions for improvements and bug reports sent through email - thanks.
New description on the FEX
Create scripts with code, output, and formatted text in a single executable document.