Error loading a just-saved matfile
이전 댓글 표시
I'm processing a bunch of participant files by saving a participant's data structure ('subjData') as a matfile, then later in the analysis pipeline I'm loading the matfiles again individually.
Saving is done using this code:
newFilename = strrep(origFilename,'.edf','.mat');
save(newFilename,'origFilename', 'subjData')
And loading is done using this code:
existingSubjMatfile = [dataDir parentfolder fname '.mat'];
load(existingSubjMatfile)
Loading works great for the first 15 or so files, then I get one of two errors when attempting to load certain files.
Error 1:
Error using load
Number of columns on line 2 of ASCII file 2003_18m/2003_18m.mat must be the same as previous lines.
Error in uiimport/runImportdata (line 461)
datastruct = load('-ascii', fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 429)
[datastruct, textDelimiter, headerLines]= runImportdata(fileAbsolutePath, type);
Error in uiimport (line 246)
gatherFilePreviewData(fileAbsolutePath);
Error 2:
Error using load
Unable to read MAT-file 2004_02m/2004_02m.mat. Not a binary MAT-file. Try LOAD
-ASCII to read as text.
When I double click the matfiles I get the same error. I've inspected the data just before saving, and nothing appears different from the other files that load just fine. What's going wrong with these particular files? (They're only around 860 kb, so not the largest of the files I'm working with)
댓글 수: 10
Walter Roberson
2018년 10월 9일
Why are you calling uiimport on a mat file?
Al_G
2018년 10월 9일
Walter Roberson
2018년 10월 9일
which -all load
Also we need the complete error message traceback, everything in red
Al_G
2018년 10월 9일
Walter Roberson
2018년 10월 9일
I see you are using Mac. At the MATLAB level, please try
!file 2003_18m/2003_18m.mat
Whatever it is appears to not be a standard .mat file.
If !file just says something like "data" then please proceed to
!od -cx 2003_18m/2003_18m.mat | head
and show us the output.
Walter Roberson
2018년 10월 9일
That file format does not match anything I happen to recognize. It does not look to be single or double precision numbers either (not impossible, but the range would be rather unusual.)
I currently have no idea how that file got to be the way it is.
How was it created, and can you re-create it? And did it happen to be like the 64th or 240th or 256th file in a sequence that was being created?
Al_G
2018년 10월 10일
Walter Roberson
2018년 10월 10일
Can you post your code, and the 15th input?
Stephen23
2018년 10월 10일
@Al_G: please upload the actual code used, by clicking the paperclip button in a new comment.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!