Error using load : Input must be a MAT-file or an ASCII file containing numeric data with same number of columns in each row.

Error using load
Unable to read file 'C:\Users\erand\Downloads\T1.mat'. Input must be a MAT-file or an ASCII file
containing numeric data with same number of columns in each row.
Error in uiimport/runImportdata (line 470)
datastruct = load('-ascii', fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 438)
[datastruct, textDelimiter, headerLines]= runImportdata(fileAbsolutePath, type);
Error in uiimport (line 260)
gatherFilePreviewData(fileAbsolutePath);

댓글 수: 5

See what this reveals:
type('C:\Users\erand\Downloads\T1.mat')
It may just produce garbage, however it may also reveal the problem.
It failed forr me as well:
LD = load('T1.mat')
Error using load
Invalid field name: 's?????_label'.
The ‘?????’ may be Unicode characters or something else that MATLAB doesn’t recognise as acceptable. There doesn’t appear to be a way to modify load to import those, since you already tried '-ascii' and that obviously didn’t work.
See if you can find a valid version of the file. There’s nothing further to be done here.

댓글을 달려면 로그인하십시오.

 채택된 답변

The binary .mat file contains invalid variable names such as
---#_label 1x1 116 cell
----#_label 1x1 116 cell
------#_label 1x1 116 cell
-------#_label 1x1 116 cell
---------#_label 1x1 116 cell
----------#_label 1x1 116 cell
--------------#_label 1x1 116 cell
-------------_label 1x1 116 cell
------------_label 1x1 116 cell
---------_label 1x1 116 cell
---------_label 1x1 116 cell
--------_label 1x1 116 cell
-------_label 1x1 116 cell
------_label 1x1 116 cell
------_label 1x1 116 cell
------_label 1x1 116 cell
----_label 1x1 116 cell
--_label 1x1 116 cell
--_label 1x1 116 cell
--_label 1x1 116 cell
--_label 1x1 116 cell
-_label 1x1 116 cell
-_label 1x1 116 cell
-b---_label 1x1 116 cell
???-_label 1x1 116 cell
???_label 1x1 116 cell
You can attempt to use the File Exchange contribution LOADFIXNAMES by @James Tursa
Unfortunately on my Mac, a message is generated about "Warning: Too many duplicate names"

댓글 수: 1

By the way, if you use
load T1.mat
without any output arguments then it will not give any warning or error, and will load all of the variables that have valid identifier names, skipping the entries that have invalid identifiers.
However, if you use
S = load('T1.mat')
or
S = load('-mat', 'T1.mat')
then it will fail, complaining about invalid variable names.
The FEX contribution, as-posted, is able to fix up some of the variable names, but not all. (I assume it could be modified to support more names.)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

질문:

2023년 7월 20일

댓글:

2023년 7월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by