Convert old matlab files to run on new MatLab version

48 views (last 30 days)
Halo,
I have a lot of old MatLab files that run on the older version of MatLab. These need to be converted so that they run on the new version. Is there any program or script that can do this?
It is mostly sign conveension like && insteed of &. But chanhging it manully is very hard as there is around a hundred files.
/Mikael

Answers (3)

Jan
Jan on 23 Aug 2012
Edited: Jan on 23 Aug 2012
There is no and there cannot be a reliable automatic conversion. You cannot simply change the & to && inside IF statements, because you have to check manually if the arguments are guaranteed to be scalars.
A source of serious troubles is findstr(Str1, Str2), which should be replaced by the safer strfind(Str, Pattern) in any case. This can be very tedious in commands like:
findstr(a.f{i}.s, myFunction(y{x}))
Without exact and exhaustive comments it will be nearly impossible which one of the inputs is the string, and which is the pattern.
The MLint warnings are a good point to start from, but hitting the FIX button is not 100% safe. So finally I can confirm, after I've fixed 120'000 lines of Matlab 5.3 code:
Changing the code manually is very hard.
Changing the code automatically will create so many bugs, that the debugging and fixing will be even harder.

Daniel Shub
Daniel Shub on 23 Aug 2012
How old is the old version of MATLAB? There are a handful for functions that have been depreciated or radically altered that you will need to make changes to accommodate. I don't know of a comprehensive list of these functions. You will have to go through the release note of every intervening version to find out which functions have changed.
Newer versions of MATLAB have additional functionality and ways of doing things more efficiently (things like && instead of &). You do not need to make these changes. In other words, your code might be more efficient if you change some of your &'s to be &&, but it is not a requirement.

Mikael
Mikael on 23 Aug 2012
It is from many different versions, with many very old ones.... Will have to do it manually then I think:(
thanks anyways

Community Treasure Hunt

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

Start Hunting!