Error message when generating table from workspace variables

조회 수: 6 (최근 30일)
Isabel Chen
Isabel Chen 2015년 1월 31일
답변: Isabel Chen 2015년 2월 1일
I tried to generate a table using the example provided in the documentation:
>> T = table(['M';'F';'M'],[45;32;34],...
{'NY';'CA';'MA'},logical([1;0;0]),...
'VariableNames',{'Gender' 'Age' 'State' 'Vote'})
Error using subsindex
Function 'subsindex' is not defined for values of class 'cell'.*
But got an error message! Please help!!

채택된 답변

Image Analyst
Image Analyst 2015년 1월 31일
Isabel:
I copied and pasted your code and it worked fine . You probably have an m-file called table.m , perhaps even the one that your code is in. That would be bad because it would conflict with the built-in table() function. What does this say
which -all table
Also, in your code, right before that line put this:
whos table
What does all that say in the command window?

추가 답변 (1개)

Isabel Chen
Isabel Chen 2015년 2월 1일
Oh goodness, thanks! This came up:
>> whos table
Name Size Bytes Class Attributes
table 4x6 2840 cell
>> which -all table
table is a variable.
C:\Program Files\MATLAB\R2014b\toolbox\matlab\datatypes\@table\table.m % Shadowed table constructor
I'm not actually sure where this 4x6 table came from, I don't remember explicitly creating it. But after deleting it, generating a new table worked fine. Thank you!!

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by