Error on opening a .mat file.

10 次查看(过去 30 天)
BdS
BdS 2018-12-12
评论: Jan 2018-12-12
I have got a rather big .mat file. When I try to open it an error message pops up: "File might be corrupt."
Here is a more detail discription if I try to import data from this file
Warning: Unable to read some of the variables due to unknown MAT-file error.
> In matfinfo (line 9)
In finfo (line 118)
In uiimport/gatherFilePreviewData (line 412)
In uiimport (line 242)
Error using load
Unknown text on line number 1 of ASCII file Q:\BGFIAV\ZENT...
Ansatz\Code\Iteration 2.2\Unit Tests\Styles\matlab.mat
"MATLAB".
Error in uiimport/runImportdata (line 463)
datastruct = load('-ascii', fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 431)
[datastruct, textDelimiter, headerLines]= runImportdata(fileAbsolutePath, type);
Error in uiimport (line 242)
gatherFilePreviewData(fileAbsolutePath);
I there a way of open it?
Thank you in advance for your help.

采纳的回答

Jan
Jan 2018-12-12
"Unknown text on line number 1 of ASCII file Q:\BGFIAV\ZENT..."
This sounds like it is a MAT file in ASCII format. Please confirm this and specify "big" in numbers. Some users assume that an 100kB file is large already, because it is hard to read by a human. Others works with medium sized files of 32GB, when their machines have 192GB RAM installed.
If the file is in ASCII format, this was a bad choice because the reading is less efficient than with binary files. Maybe a specific routine for reading the ASCII file is better than the general purpose load. Please post a small but relevant part of the file.

更多回答(1 个)

BdS
BdS 2018-12-12
The file is 644'234 KB big. My computer is not the latest one. How to check if my .mat file is in ASCII format?
  1 个评论
Jan
Jan 2018-12-12
Please post comments in the sections for comments, not as answer.
Open the file in an editor - e.g. Matlab's or Notepad++. The later handles large files more efficiently than e.g. the built-in Editor of Windows. Alternatively open the file in Matlab with fopen and use fread to read the 1st 100 characters. If you can read this, it is ASCII.
If you import a 644 MB text file to Matlab, you need 1.2GB of free RAM, because the characters are stores with 2 bytes. If you want to perform calculations with these data, a concersion to doubles is required at all. So better convert the data during the import already.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by