How to deal with corrupted matlabprefs?

102 次查看(过去 30 天)
LucasBar
LucasBar 2024-8-19,16:55
评论: LucasBar 2024-8-23,16:45
I run a matlab-script that use batch processing to collect sample from different sensors at same time.
Some sensors are connect using UDP protocol, modbus, and serial port.
As a rule, they work fine. However, sometimes I have an error related to matlabprefs.mat.
As a consequence, one of the sensors can stop to collect data, i.e., I can not read correctly form a specific serial port, and in the next time I run the same matlab script, it will fail producing some complaining about "matlabprefs.mat" (see example below).
I have this problem frequently.
I am affraid becasue If I can not deal properlly with this problem,I can not trust on matlab to control my data sample system.
Please, could you help me to figure out a deffinitive solution for this issue?
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 C:\Users\user\AppData\Roaming\MathWorks\MATLAB\R2023a\matlabprefs.mat. File might be corrupt.
> In hgrc (line 151)
In matlab.graphics.internal.initialize (line 15)
  9 个评论
Walter Roberson
Walter Roberson 2024-8-23,1:56
What you are asking about happens to be beyond the experience of @Steven Lord . Steven Lord happens to work for Mathworks, but when he posts here, he posts as a volunteer. He is recommending that you contact Mathworks Technical Support.
LucasBar
LucasBar 2024-8-23,16:45
Ok, I just have to say thanks to @Steven Lord.
I already posted the issue on Mathworks Techinical Support.
My best regards

请先登录,再进行评论。

回答(1 个)

Animesh
Animesh 2024-8-19,17:00
  2 个评论
LucasBar
LucasBar 2024-8-19,18:52
"removing the file helps for some time"
I know this might be a shortcut, but is not a solution. Once the error occurs, it will end the data processing and will not allow matlab starts correctly again. It is not desired that the program starts again, because there is a production chain linked to the script. Imagine this script running an airplane. Matlab should be able to fix this error, without having to restart matlab.
LucasBar
LucasBar 2024-8-19,18:53
We can not just remove the result of an error without solve the error because this error will came back.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by