How can you write a matlab code from the 2018 version back to the 2013b version?
Show older comments
How can you write a matlab code from the 2018 version back to the 2013b version?
Is there an overview available which codes have changed with the change of matlab 2013?
4 Comments
Lisa van de Wiel
on 7 Feb 2022
Lisa van de Wiel
on 7 Feb 2022
You will have to rewrite the use of the table datatype to struct. Then you can replace removerars by rmfields.
Occurrences of datetime should be replaced by datenum. Not every interface function will be available.
Edit: I should have checked. The table datatype was introduced in R2013b. I though that would have been later, hence my suggestion of replacing it with struct.
DATETIME objects cannot be replaced by any one inbuilt function or class supported by earlier versions. How to replace the DATETIME objects depends on what they are being used for and what methods are used, which you have not told us.
REMOVEVARS might be able to be replaced by some indexing:
Answers (1)
"How can you write a matlab code from the 2018 version back to the 2013b version"
By very carefully reading the documentation for those two versions, for all operators, indexing, functions, etc.
It is certainly possible, if the motivation is there, but might involve a lot of work. Or none at all. It depends.
"Is there an overview available which codes have changed with the change of matlab 2013?"
An overview you can find here:
and also on other sources, e.g. Wikipedia. Unfortunately the official Release Notes currently covers only from 2016b, so will not cover your earlier version (and there have been several major changes since your earlier version, such as expanding arithmetic, new GUI engine, popular new classes, etc.).
The ultimate check is simply to run it on the versions in question (a comprehensive set of test-cases will help here).
3 Comments
Walter Roberson
on 4 Feb 2022
The amount of work involved might be several years, if the code relies upon new features. For example if the code involved running a Convolution Neural Network on GPU, it could be a considerable burden to get to work in 2013 MATLAB.
Rik
on 4 Feb 2022
As Stephen and Walter hinted: this is extremely dependent on the functions you're using. Most basic functions will work without any change. Sometimes there are tiny fixes, while other will require an unrealistic amount of work to get going.
I personally try to make sure all my published functions are compatible with every release back to Matlab 6.5 (R13), as well as GNU Octave. If you get into the habit it isn't that difficult or much effort. That is a very different use case from receiving a piece of code and getting it to work on an older release though.
The best way is to write a comprehensive test function to make sure you have the desired effects. To confirm I do indeed get the same results, I have even written a hashing function so I can compare the exact output between releases with a simple strcmp call.
If you want to write code for older versions, have fun. Like Stephen notes, the online release notes will be pretty much irrelevant. You need to dig up the PDF release notes for base MATLAB as well as any toolboxes you're using. Sit down and read everything relevant across all the versions from R2013b to whatever version you're using.
They're buried on separate pages under here:
For example, the MATLAB RN goes back to about R2012b (toward bottom of list):
The Image Processing Toolbox RN goes back further:
Similarly, you may find tidbits of lost information among the archived documentation.
Bear in mind that without testing on those older versions as Rik suggests, you're relying on the release notes and documentation disclosing all changes and describing them accurately.
You may also find when() useful for making sure the tools you're using existed in prior versions. That helps to get the version numbers to use with ifversion() for switching version-dependent code sections.
Categories
Find more on Structures 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!