Identify Matlab Version used to create a .m file
17 views (last 30 days)
Show older comments
Is there any way of identifying with which version of matlab a particular .m file has been created?
0 Comments
Accepted Answer
Daniel Shub
on 4 Nov 2011
No. You do not need MATLAB to create .m files. The MATLAB editor does not insert any meta data about its version in the .m file.
A related question is trying to determine the version of MATLAB that the .m file was created FOR. In other words, which versions of MATLAB can the .m file be run on. MATLAB has introduced some "syntax" changes (e.g., ~ as a placeholder and parfor). You could use the presence of these changes to roughly track a version. Other things like new functions are not possible. You cannot tell from looking at the code if a function call is a call for a new built-in function or a old function taken from the FEX.
4 Comments
Jan
on 4 Nov 2011
@Daniel: Does this work seamlessly using different Matlab releases for testing? After changing the code, the former successful tests are not valid anymore. So you need something like:
$Tested: Version from 23-Nov-2010 23:10:17 tested under Matlab 2008a$
$Tested: Version from 23-Nov-2010 23:10:17 tested under Matlab 2009b$
While all messages like $Tested: version from 22-Nov...$ should disappear automatically.
Daniel Shub
on 4 Nov 2011
@Jan, I don't currently reliably unit test and I definitely don't unit test on multiple releases yet, so I am not sure how I would do handle the commenting part. I am pretty sure keywords ("Tested" in your example) can only have one value (although it can be a multi-line value) so it isn't as easy as your example. That said, I don't see any reason that you couldn't get something like that to work. If you invoked the multi-release unit test from a BASH script you could have the script keep appending things to the keyword replacement string.
More Answers (0)
See Also
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!