This tool is intended to show you how to fix v5 MAT-Files saved ONLY with R14FCS MATLAB 7.0.0, which the MATCAT tool determined to have zero size in the tag of a variable. This tool does not modify the MAT-File unless you use the optional second input argument, 'fix', in which case the file is fixed automatically, but only for the first (most common) case shown below.
The zero-size-in-tag issue has two possible causes:
(1) the most likely cause is specific to MATLAB 7.0.0, which only happens in rare cases, and is fixed in R14sp1, and thus can be avoided altogether by using MATLAB 7.0.1 or later (R14sp1 or later). If this is the cause of the zero tag in your MAT-File, then this tool (matzerofix) can either show you how to fix it yourself, or fix the MAT-File automatically.
The data of such a zero-size-in-tag variable is saved correctly, only the variable's tag says zero data bytes (incorrect), thus causing MATLAB to be unable to load the file. Once the MAT-File is fixed by setting the correct size in the tag, the file will load correctly in MATLAB.
(2) the other possible cause is specific to MATLAB 7.0.0 through 7.0.4 and is due to a variable that is skipped during save. In this case, an extra 8 byte tag which should not be there is saved in the MAT-File. This will be fixed in R14sp3. This tool (matzerofix) does not fix this problem.
To fix such a file, the file must be copied to a new file, excluding the 8 byte tag at the offset indicated by matzerofix. For example, if you have a 200 byte MAT-File with a zero tag at offset 128, copy bytes 0-127 to a new file, skip bytes 128-135, then continue with bytes 136 until the end of the file. If there are more such tags, you may need to repeat the process until all are excluded, then it will load correctly in MATLAB.
matzerofix mymatfile.mat fix
You should download the MATCAT tool and diagnose your MAT-File first
to determine whether you need to use this (MATZEROFIX) tool on your file.
>> matzerofix myfile.mat
byte 128 compressed var size offset 132 data bytes 82
byte 218 compressed var size offset 222 data bytes 0 <-INCORRECT
correct this value like this:
byte 308 compressed var size offset 312 data bytes 339
I can't seem to get this to run...?
Potentially related: when I downloaded it, it had many extra carriage returns in it that I had to delete manually.