Error: MAT file cannot be loaded because it contains duplicate variables

조회 수: 5 (최근 30일)
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?

채택된 답변

Oliver Johnson
Oliver Johnson 2016년 3월 10일
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.

추가 답변 (1개)

James Tursa
James Tursa 2016년 3월 2일
편집: James Tursa 2016년 3월 2일
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.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by