writetable error line183, the first argument must be a table

1 view (last 30 days)
I use the original code getting from Matlab website, which is as follows.
And the error was ''Error using writetable, First argument must be a table (line183)".
My matlab version is R2020b
Cause the code is from the authority, it supposely does work. However, it does not work
T = table(['M';'F';'M'],[45 45;41 32;40 34],...
{'NY';'CA';'MA'},[true;false;false])
writetable(T)
THIS IS THE SNAPSHOT
  2 Comments
Steven Lord
Steven Lord on 24 Feb 2022
That error message doesn't look like a MathWorks written error message, and when I tried an experiment using release R2020b that's not the message I received. Can you confirm that you copied it verbatim from the Command Window into your Answers post? If you didn't copy it verbatim, could you please do so in a comment? Was this the error you received?
cd(tempdir)
writetable(42)
Error using writetable (line 248)
Unsupported type 'double'. Use writematrix instead.
Wei Du
Wei Du on 25 Feb 2022
the error I received is like
Error using writetable (line 183)
First argument must be a table.
>> writetable(T)

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 24 Feb 2022
Use
which -all table
/MATLAB/toolbox/matlab/datatypes/tabular/@table/table.m % table constructor /MATLAB/toolbox/matlab/testframework/unittest/core/+matlab/+unittest/TestResult.m % Shadowed matlab.unittest.TestResult method /MATLAB/toolbox/matlab/testframework/unittest/core/+matlab/+unittest/+internal/BaseTestResult.m % Shadowed matlab.unittest.internal.BaseTestResult method /MATLAB/toolbox/matlab/bigdata/@tall/table.m % Shadowed tall method /MATLAB/toolbox/parallel/parallel/@distributed/table.m % Shadowed distributed method /MATLAB/toolbox/parallel/parallel/@codistributed/table.m % Shadowed codistributed method
to find out which function named table you are invoking. You should be seeing that tabuluar/@table/table.m as the first entry on the list, but it sounds as if you have some other function named table.m that is interfering.
  12 Comments
Walter Roberson
Walter Roberson on 4 Mar 2022
Did you delete D:\iProgramFiles\toolbox\spm12\external\fieldtrip\compat\matlablt2013b folder ?
Wei Du
Wei Du on 4 Mar 2022
Yes.
And after I run
restoredefaultpath; rehash toolboxcache
I added SPM12 toolbox again, and this time I delete ...compat\matlablt2013b and other similar compat\matlab2016b etc
Then I try writetable function.
It worked now.
Thank God, finally!
THANK YOU!!

Sign in to comment.

More Answers (0)

Categories

Find more on Instrument Control Toolbox Supported Hardware in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!