Error loading matlabprefs.mat

60 visualizaciones (últimos 30 días)
Andreas Schwager
Andreas Schwager el 18 de Jun. de 2021
Respondida: LucasBar el 6 de Ag. de 2024
Hallo,
there is an error:
MATLAB:load:notBinaryFile
Unable to read MAT-file /home/myUser/.matlab/R2021a/matlabprefs.mat. Not a binary MAT-file. Try load -ASCII to read as text.
sometimes (this is not reproducible) it pops up after rebooting Matlab:
Warning: Initializing MATLAB Graphics failed.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:load:unableToReadMatFile
Unable to read MAT-file /home/myUser/.matlab/R2021a/matlabprefs.mat. File might be corrupt.
> In hgrc (line 163)
In matlab.graphics.internal.initialize (line 15)
Some pages (e.g. https://www.mathworks.com/matlabcentral/answers/364986-matlab-error-graphic) recommend deleting matlabprefs.mat. However, if I do, the error pops up again.
I also deleted full ~/.matlab folder. The error was gone for a couple of hours. Now, it reappears.
Does anybody know a persistent solution?
Thanks
  6 comentarios
Andreas Schwager
Andreas Schwager el 18 de Jun. de 2021
Editada: Andreas Schwager el 18 de Jun. de 2021
file ~/.matlab/R2021a/matlabprefs.mat
~/.matlab/R2021a/matlabprefs.mat: Matlab v5 mat-file (little endian) version 0x0100
Walter Roberson
Walter Roberson el 18 de Jun. de 2021
That looks okay at the moment. At a time that MATLAB is telling you the file is corrupt, could you attach the file here for us to look at?
(Note: I am not completely sure where MATLAB stores github keys, or login credentials to reach your Mathworks account, and it is plausible they might be stored in that file, so there is some degree of security risk; I do not know if they are stored in that file or not, or how they might be encoded.)

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 19 de Jun. de 2021
Editada: Jan el 25 de Jun. de 2021
If removing the file helps for some time, a function is destroying the file. Then an approach is to scan, who is accessi ng the file. Shadow the builtin save() function by adding this in a folder ontop of the path:
function save(varargin)
file = varargin{1};
if contains(file, 'matlabprefs', 'IgnoreCase', true) % [EDITED, Typo fixed]
disp(dbstack)
end
str =
evalin('caller', ['builtin(''save''', strjoin(varargin{:}, ',')]);
end
Does this work?! The strange calling syntax of the save() command, which takes char vectors as input to access the contents of the corresponding variables, is hard.
  8 comentarios
Jan
Jan el 25 de Jun. de 2021
@Andreas Schwager: This is the purpose of the code I've posted: Preventing SAVE to access the preferences file or to track, who is corrupting it.
Andreas Schwager
Andreas Schwager el 25 de Jun. de 2021
Dear Jan,
yes, I do not know when or why, however Matlab requires me to validate the local PCT cluster. This fails, if save is prevented. So, in the long term, there must be any better solution.

Iniciar sesión para comentar.

Más respuestas (1)

LucasBar
LucasBar el 6 de Ag. de 2024
I have this matlabprefs.mat corrupted while I was using batch(). I had 5 sensors collecting data simultaneously, each job batch were reading information from different serial ports. Suddenly, this matlabprefs.mat was corrupted and one sensor stopped to save data. How I could deal with this kind of error. I can not reboot matlab or computer for that. I need to keep my processing running.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by