MATLAB: How much backward compatibility is there in .fig files

figure

In particular, if I have a .fig file generated in R2018a, should I be able to read it, say, in R2009? I have never kept track of which version my .fig files were created in versus which Matlab version I used to load them, and this has never created any problems for me. Is there some deliberate backward compatibility mechanism that TMW uses to ensure this, or was it just random luck?

Best Answer

Modern .fig files store objects both for HG2 and HG1 unless you savefig with 'compact'
However, because you can attach any kind of data to most graphics objects, you can end up with fig files that include objects in a format that is not compatible with before R2008a (approximately), a couple of releases after the new style objects were introduced. There was a bug in the representation of the new style objects, so the incompatibility a few releases later was necessary to fix the problem.
The modern object format deals with backwards compatibility by encoding objects as a series of bytes, and saying that if the object definition is not available in a release (perhaps because the object type had not been invented yet) then the object is retrieved as a byte stream. I seem to recall that the arrangement is not backwards compatible to the release before the new style objects were invented. There was a period between where they were invented and when they were publicly released that had the support, so reading the release notes is not always good enough to determine backwards compatibility.