Why do I get this error when loading a Matlab created file?
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
Voss
2022-5-1
Can you upload one of the mat files that gives you this error? (Upload a file using the paperclip button.)
dpb
2022-5-1
编辑:dpb
2022-5-1
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.
回答(1 个)
Krishna
2022-8-26
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!