Problem Loading a Design Matrix File

1 view (last 30 days)
Paige Oden
Paige Oden on 4 Jun 2019
Edited: dpb on 4 Jun 2019
I am attempting to load a design matrix titled R_Hipp_all.mat into Matlab. However, all I'm getting are errors. If I click on the file, I get the following error:
Error using load
Number of columns on line 3 of ASCII file /Users/paigeoden/data/R_Hipp_all.mat
must be the same as previous lines.
Error in uiimport/runImportdata (line 465)
datastruct = load('-ascii', fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 433)
[datastruct, textDelimiter, headerLines]=
runImportdata(fileAbsolutePath, type);
Error in uiimport (line 244)
gatherFilePreviewData(fileAbsolutePath);
If I try to open it within Matlab, I recieve this error:
load('R_Hipp_all.mat')
Error using load
Unable to read MAT-file /Users/paigeoden/data/R_Hipp_all.mat. Not a binary MAT-file.
Try load -ASCII to read as text.
Along with the bottom left box saying "Error loading the selected Matlab file." Does anyone know why this might be happening?

Answers (1)

dpb
dpb on 4 Jun 2019
The first error message tells you precisely why it's happening -- the third line of the file doesn't have the same number of values/delimiters as do the previous two lines. load -ascii can only handle regular files.
Whoever named the file with a .mat extension erred in doing so as it leads to expectations of what file content will be that aren't met with this particular file.
We would have to see the file to be able to have any more suggestions regarding how to read it specifically; in general there is textscan for fscanf which can read most any file structure but have to be coached on how to do so if the data isn't totally regular in pattern.
  4 Comments
Paige Oden
Paige Oden on 4 Jun 2019
Thank you! This is probably a silly question, but how were you able to look at the file like that?
dpb
dpb on 4 Jun 2019
Well, I did that by simply clicking on your link and "open in new tab" -- but just use a text editor like any other text file...

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!