Why do I get this error when loading a Matlab created file?

28 Ansichten (letzte 30 Tage)
Brianna Miranda
Brianna Miranda am 1 Mai 2022
Beantwortet: Krishna am 26 Aug. 2022
This is the full error message that I am receiving. I created these files in matlab and when I try to load them I get the following error message:
Error using load
Unable to read MAT-file /Users/........./Vs.mat. Not a binary MAT-file. Try load -ASCII to read as
text.
I tried using load('Vs.mat','-ascii') but this creates a blank vector and I am trying to load a vector.
  3 Kommentare
Voss
Voss am 1 Mai 2022
Can you upload one of the mat files that gives you this error? (Upload a file using the paperclip button.)
dpb
dpb am 1 Mai 2022
Bearbeitet: dpb am 1 Mai 2022
Probably get same/similar error, but for grins what does
whos -file Vs
return?
Can you create/read (save/load) a new .mat file now successfully?
It does seem like every once in a while for no explicable reason a .mat file does get corrupted in my experience but there's never been any time where could reproduce a symptom in order to be able to file bug report.
Just for confirmation, if the .mat file was created interactively from the command line, can you recall from the commandhistory the specific command used to create it? If was from a script or in a function or used the GUI interface, this will be a non-starter, but occasionally can use the command history and recover after a user error.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Krishna
Krishna am 26 Aug. 2022
I understand that you are facing issue while running matlab files. One reason you may be receiving the error "Unable to read MAT-file" is because multiple instances of MATLAB running on the same machine are not inherently synchronized when accessing shared resources. If two instances of MATLAB are accessing the same data, there is a chance the data may become corrupted.
A possible workaround for this issue would be to create a "lock" file for each instance of MATLAB, and before performing any operations on the data, check to ensure the other instance's "lock" file doesn't exist. This would indicate if it is safe to read or write to that MAT-file.Attached is a pair of files, "writer.m" and "reader.m". These files demonstrate one possible workflow for creating these "lock" files.
I hope this solves your issue.

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by