It turns out the problem was that MATLAB closed before the MAT file was finished saving, so it was just corrupted. The solution was (unfortunately) to just recompute and save it again.
Error: MAT file cannot be loaded because it contains duplicate variables
2 views (last 30 days)
Show older comments
Oliver Johnson
on 2 Mar 2016
Answered: Oliver Johnson
on 10 Mar 2016
I saved 10 very large MAT files that contain simulation results (each is the result of running the same script, with different input parameters, on 10 separate nodes of a supercomputer). For some reason, one of these files (the second one that was saved) has a problem, and MATLAB gives the following error message: "MAT file cannot be loaded because it contains duplicate variables." However, all 10 of the MAT files that were created contain the same variables and there are no duplicate variables in any of the other MAT files.
I have two questions: (1) Is there any workaround to access the data in this MAT file? (2) Does anyone know how this might have happened so I can avoid it in the future?
0 Comments
Accepted Answer
More Answers (1)
James Tursa
on 2 Mar 2016
Edited: James Tursa
on 2 Mar 2016
If you have a C compiler installed, you might try this FEX submission which uses a mex routine to load variables one-by-one and fix names as it goes:
It loads a mat file and has some name clash avoidance capability. To be honest I don't remember what I put in for this so I am not at all sure this will work for your case. But it is worth a try (if you have a C compiler). If you don't have a C compiler, maybe you can locate a 32-bit version of MATLAB to use (which comes with a C compiler) for the loading process ... you can always save the results for subsequent loading under your original MATLAB.
If MATLAB did indeed create this file, this sounds like a bug or a corrupted file.
0 Comments
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!