Issues using 'readtable' (MATLAB 2024a)
显示 更早的评论
The following code had worked in the past to read Excel files as tables in MATLAB.
elec_list = readtable('/Users/.../preprocessed_data/databases/elec_list.xlsx', 'Sheet','main');
Recently, the same code doesn't work (no paths or filenames have been changed) and yields the following error:
Error using ones
Size inputs must be scalar.
Error in any (line 65)
sz = [sz,ones(1,DIM-length(sz))];
Error in readtable (line 501)
if any(cellfun(@(arg) isa(arg,"matlab.io.ImportOptions"),varargin),'all')
A few things I tried:
- Running the code in MATLAB 2023b and MATLAB 2024a
- Testing which version I am using:
which readtable
/Applications/MATLAB_R2024a.app/toolbox/matlab/iofun/readtable.m
3. Using the MATLAB interactive environment I try loading the data but it says it contains uninterpretable data.

I checked the Excel file and it is not corrupted. I tried created the file from de novo and then copying the data making sure nothing was weird. This didn't work.
Thank you for your help.
采纳的回答
Let's check that you haven't accidentally defined a length.m function that does not behave the same way as the one included in MATLAB. What does this display?
which -all length
built-in (/MATLAB/toolbox/matlab/elmat/length)
built-in (/MATLAB/toolbox/matlab/elmat/@double/length) % double method
built-in (/MATLAB/toolbox/matlab/elmat/@int16/length) % int16 method
built-in (/MATLAB/toolbox/matlab/elmat/@int32/length) % int32 method
built-in (/MATLAB/toolbox/matlab/elmat/@int64/length) % int64 method
built-in (/MATLAB/toolbox/matlab/elmat/@int8/length) % int8 method
built-in (/MATLAB/toolbox/matlab/elmat/@logical/length) % logical method
built-in (/MATLAB/toolbox/matlab/elmat/@single/length) % single method
built-in (/MATLAB/toolbox/matlab/elmat/@uint16/length) % uint16 method
built-in (/MATLAB/toolbox/matlab/elmat/@uint32/length) % uint32 method
built-in (/MATLAB/toolbox/matlab/elmat/@uint64/length) % uint64 method
built-in (/MATLAB/toolbox/matlab/elmat/@uint8/length) % uint8 method
length is a built-in method % string method
/MATLAB/toolbox/matlab/lang/+matlab/+mixin/@Scalar/Scalar.m % dictionary method
/MATLAB/toolbox/matlab/datatypes/categorical/@categorical/length.m % categorical method
/MATLAB/toolbox/matlab/graphfun/@digraph/digraph.m % digraph method
/MATLAB/toolbox/matlab/graphfun/@graph/graph.m % graph method
/MATLAB/toolbox/matlab/datatypes/tabular/@tabular/tabular.m % tabular method
/MATLAB/toolbox/matlab/datatypes/datetime/@datetime/datetime.m % datetime method
/MATLAB/toolbox/matlab/datatypes/duration/@duration/duration.m % duration method
length is a built-in method % matlab.internal.capability.Capability method
length is a built-in method % connector.internal.LoggerLevel method
length is a built-in method % matlab.lang.OnOffSwitchState method
/MATLAB/toolbox/matlab/indexing/+matlab/+mixin/+indexing/@RedefinesParen/length.m % matlab.mixin.indexing.RedefinesParen method
length is a built-in method % containers.Map method
length is a built-in method % matlab.internal.reference.property.RefEntityType method
length is a built-in method % matlab.internal.reference.api.EntityPrecision method
length is a built-in method % matlab.internal.reference.property.DeprecationStatus method
length is a built-in method % matlab.internal.reference.property.FunctionType method
length is a built-in method % matlab.internal.reference.property.SyntaxType method
length is a built-in method % matlab.internal.reference.api.EntityCaseSensitivity method
length is a built-in method % simulink.FindSystemTask.Status method
length is a built-in method % mf.zero.meta.Language method
length is a built-in method % dig.config.CommandType method
length is a built-in method % dig.config.HorizontalAlignment method
length is a built-in method % dig.config.ResourceState method
length is a built-in method % dig.config.ResourceType method
length is a built-in method % dig.model.DisplayState method
length is a built-in method % dig.model.EventDataType method
length is a built-in method % dig.model.FunctionType method
length is a built-in method % dig.model.ValidInBdType method
length is a built-in method % dig.model.ViewMode method
length is a built-in method % matlab.unittest.internal.fixtures.FolderScope method
length is a built-in method % matlab.automation.Verbosity method
length is a Java method % java.io.File method
length is a Java method % java.lang.String method
length is a Java method % java.lang.CharSequence method
length is a built-in method % matlab.internal.timer.CallBackTypeEnum method
length is a built-in method % matlab.internal.timer.BusyModeEnum method
length is a built-in method % matlab.internal.timer.ExecutionModeEnum method
/MATLAB/toolbox/matlab/bigdata/@tall/length.m % tall method
built-in % gpuArray method
/MATLAB/toolbox/matlab/serial/@serial/length.m % serial method
/MATLAB/toolbox/matlab/timeseries/@tscollection/length.m % tscollection method
/MATLAB/toolbox/icomm/opc/opc/@opcroot/length.m % opcroot method
/MATLAB/toolbox/imaq/imaq/@videoinput/length.m % videoinput method
/MATLAB/toolbox/instrument/instrument/@udp/length.m % udp method
/MATLAB/toolbox/instrument/instrument/@icgroup/length.m % icgroup method
/MATLAB/toolbox/instrument/instrument/@icdevice/length.m % icdevice method
/MATLAB/toolbox/instrument/instrument/@tcpip/length.m % tcpip method
/MATLAB/toolbox/instrument/instrument/@Bluetooth/length.m % Bluetooth method
/MATLAB/toolbox/instrument/instrument/@gpib/length.m % gpib method
/MATLAB/toolbox/instrument/instrument/@visa/length.m % visa method
/MATLAB/toolbox/instrument/instrument/@i2c/length.m % i2c method
/MATLAB/toolbox/parallel/array/distributed/@codistributed/length.m % codistributed method
/MATLAB/toolbox/parallel/array/distributed/@distributed/length.m % distributed method
/MATLAB/toolbox/parallel/gpu/gpu/@gpuArray/length.m % gpuArray method
/MATLAB/toolbox/parallel/lang/@Composite/length.m % Composite method
/MATLAB/toolbox/robust/rctobsolete/robust/@icsignal/length.m % icsignal method
/MATLAB/toolbox/shared/statslib/@dataset/length.m % dataset method
1 个评论
Comparing our outputs, I have a few extra ones coming from toolboxes (MATLAB native and extra ones).
I tried the logical step:
restoredefaultpath
After doing this, my readtable function works. This makes suspect that the eeglab "length.m" functions is the one causing the issues. How should I deal with this issue? Renaming the function from the toolbox (which seems a bit problematic) or what else?
>> which -all length #before doing restoredefaultpath
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/length)
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@double/length) % double method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@int16/length) % int16 method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@int32/length) % int32 method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@int64/length) % int64 method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@int8/length) % int8 method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@logical/length) % logical method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@single/length) % single method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@uint16/length) % uint16 method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@uint32/length) % uint32 method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@uint64/length) % uint64 method
built-in (/Applications/MATLAB_R2024a.app/toolbox/matlab/elmat/@uint8/length) % uint8 method
length is a built-in method % string method
length is a built-in method % matlab.lang.internal.FunctionInvocationType method
length is a built-in method % matlab.internal.capability.Capability method
length is a Java method % java.io.File method
length is a built-in method % connector.internal.LoggerLevel method
length is a Java method % java.lang.String method
length is a Java method % java.lang.CharSequence method
length is a built-in method % containers.Map method
length is a built-in method % matlab.desktop.editor.RtcEditorState method
length is a built-in method % matlab.lang.OnOffSwitchState method
/Users/camilocastelblanco/Dartmouth College Dropbox/Camilo Castelblanco Riveros/ieeg-mimetic/analysis_scripts/main/matlab_scripts/matlab_toolboxes/eeglab2023.0/functions/@mmo/length.m % mmo method
/Users/camilocastelblanco/Dartmouth College Dropbox/Camilo Castelblanco Riveros/ieeg-mimetic/analysis_scripts/main/matlab_scripts/matlab_toolboxes/eeglab2023.0/functions/@memmapdata/length.m % memmapdata method
/Users/camilocastelblanco/Dartmouth College Dropbox/Camilo Castelblanco Riveros/ieeg-mimetic/analysis_scripts/main/matlab_scripts/matlab_toolboxes/eeglab2023.0/functions/@eegobj/length.m % eegobj method
/Applications/MATLAB_R2024a.app/toolbox/matlab/bigdata/@tall/length.m % tall method
/Applications/MATLAB_R2024a.app/toolbox/matlab/serial/@serial/length.m % serial method
built-in % gpuArray method
/Applications/MATLAB_R2024a.app/toolbox/matlab/datatypes/categorical/@categorical/length.m % categorical method
/Applications/MATLAB_R2024a.app/toolbox/matlab/timeseries/@tscollection/length.m % tscollection method
/Applications/MATLAB_R2024a.app/toolbox/parallel/lang/@Composite/length.m % Composite method
/Applications/MATLAB_R2024a.app/toolbox/parallel/array/distributed/@codistributed/length.m % codistributed method
/Applications/MATLAB_R2024a.app/toolbox/parallel/array/distributed/@distributed/length.m % distributed method
/Applications/MATLAB_R2024a.app/toolbox/parallel/gpu/gpu/@gpuArray/length.m % gpuArray method
/Applications/MATLAB_R2024a.app/toolbox/shared/statslib/@dataset/length.m % dataset method
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
标签
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
