Is there a tool to make a program compatible with an older version of MATLAB? Backwardsc​ompatibili​ze...

27 views (last 30 days)
The situation is this: I've written and maintained a toolbox for image data analysis over a ~10 year period. During this time matlab has gone through a number of versions, and I've made the modifications to keep my program running in "my current MATLAB". Initially there were not (m)any other users, but now there is a slowly growing number of users. Then there is problems when they are using older versions of MATLAB, sometimes even releases that I for one reason or the other skipped. Now with 20-20 hindsight, I realize that I should've kept the tools backwards compatible as I went ahead, but that was often not done...
Now to the question: Is there anyone that has "solved" this problem, that is developed practices, routines, or even tools to make the backwardcompatibilization? Is there any advice or tips to ease this, or will I be forced into a messy-n-massive coding slog?

Accepted Answer

Jan
Jan on 9 Feb 2011
I'm programming for Matlab 6.5 and 2009a. I avoid the new features for backward compatibility: No Java, UITABLE, TREEVIEW, ACCUMARRAY, BSXFUN, REGEXP('split'), OO, ... But there are a lot of futher unexpected incompatibilities: PLOT replies line handles in Matab 6.5, but lineseries handles in 2009a. DATENUM('7:30') uses the current date in 2009a, but 00-Jan-0000 in 6.5. This list could be continued until tomorrow. Therefore I'm sure, that an automatic tool might find some obvious incompatibilites, but this will never be exhaustive or even reliable.
I've created some backported function to support new standard functions: ANCESTOR, an efficient ISFIELD, TYPECAST, BSXFUN, COMMANDWINDOW, ... Some of these functions can be found in the FEX - others seem to have the same needs...
Unit-testing would be a good idea: Install your program on a specific Matlab version and test it exhaustively. If no error occurs, there is a good chance, that your program is compatible with the specific Matlab version.
  2 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 9 Feb 2011
That we could continue compiling the list till the sun rises next week is just the problem. The prime example I got to face was the usage of || and &&, a user group was using an older version of matlab that did not support those so we had to strip off all those. In a package with 500 files that becomes tiresome. Even if an automatic "reversionizer" would only make a good fraction of the fixes needed (unreliably even) it would give a good head start, at least pointing out stuff that's likely to need attention. Unit testing is of course the organized way to find out what needs to be fixed.
An idea that just struc is that since it is be possible to use mlint to get pointers to error it would be realy nice if mlint had a setting/keyword for 'matlab-version'.
Jan
Jan on 9 Feb 2011
It would be very helpful already, if TMW adds a list of changes in the help section of each M-file. If a customer asks me, if his 2007a version supports the 'split' flag of REGEXP, the best solution is asking him to try it. FOPEN does not support the numeric VAX-D format since 2008b anymore, but this was not mentioned in the docs at all.
However, if I try to compile modern C-code with a C89 compiler, incompatibilities will occur also. Matlab has a good inter-release-compatibility, but for a really trustworthy and reliable program you have to limit the usage to a single Matlab release.
This is the cause for letting me ask for a long-term-supported release whenever I find a chance to.

Sign in to comment.

More Answers (2)

Patrick Kalita
Patrick Kalita on 8 Feb 2011
This answer is about the mechanics of how to check the MATLAB version from your code. Maybe your question was more broad than that, but in case you weren't aware of them there are a few functions which you might find useful. I think the best option is the verLessThan function. From its help section:
if verLessThan('matlab', '7.0.1')
% Put code to run under MATLAB older than MATLAB 7.0.1 here
else
% Put code to run under MATLAB 7.0.1 and newer here
end
The verLessThan function itself was introduced in MATLAB R2007a. Anyone using a version older than that can download a copy of it from this solution.
You can also use the ver command and do your own string comparisons with the values in the structure it returns:
>> V = ver('MATLAB')
V =
Name: 'MATLAB'
Version: '7.11'
Release: '(R2010b)'
Date: '03-Aug-2010'
>>
That will involve a little more work on your part, but it does give you a little more flexibility (you could do a switch-case statment to discriminate between many versions) and this syntax will work going back to at least MATLAB R13sp2.
  2 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 8 Feb 2011
Yes, I'm aware of those, but my question was indeed broader than that, kind of "any tricks to change the stuff that have to go in after verLessThan". Thanks for this starter...
Jan
Jan on 9 Feb 2011
The linked verLessThan function fails to distinguish Matlab v7.10 and v7.1. You can use isMatlabVer: http://www.mathworks.com/matlabcentral/fileexchange/27231 . It is very funny, that just this tool to check versions suffers from version numbers, which are defined by MathWorks.

Sign in to comment.


Erik Newton
Erik Newton on 9 Mar 2024 at 16:19
It's early days, but I've just started this project: https://github.com/enewton/matlab-backports
It's an attempt to implement some of the simple helper functions which appear in each new release, to help you run newer code with an older MATLAB version.
  2 Comments
DGM
DGM on 10 Mar 2024 at 0:43
Nice. I've reimplemented a few things in MIMT (e.g. the various changes to colormap generators), but at least the version-compatibility things I don't bother implementing in an identical manner.
It'd be nice to see a clim()/caxis() alias.

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!