Issue with table functions

Hi, I had some table code working until recently, I now can't import tables (from some searching this is possible due to a microsoft update. gah). I was working around an issue using table import to create a table with my desired headings and one row of data. As I can't do this anymore I need to solve original problem.
I have some data as an array that I want to stick in a table with set heading and then append some columns. I'm having issues with renaming variables or adding to a blank table. Simple, example code:
results=magic(5);
T1=array2table(results);
T1.Properties.VariableNames = {'a','b','c','d','e'};
Firstly, if I try and run this I get "Too many input arguments" error. I have also tried renaming within a loop with same error. As I also want to append some columns, I've also tried.
T2= cell2table(cell(0,7), 'VariableNames', {'rndm','target','a','b','c','d','e'});
T2.a=T1.results1; %%or
T2.a(:,1)=results(:,1);
T2.rndm(1,1)='no';
I am also getting ""Too many input arguments"
Again, I've seen posts with this sort of code working, e.g.
vnames = {'Exp', 'Strike', 'Put_Mark', 'Put_Ask', 'Put_Bid', 'Put_Delta', 'Put_ImplVol', 'Date', 'DateNM'};
optionsChange = array2table(zeros(0,9), 'VariableNames',vnames);
optionsChange.Date = zeros(1,3); % simple way to get a 0x1 datetime
optionsChange.DateNM = datetime(zeros(1,3));
summary(optionsChange)
This code does not work for me also, with the same error. Is this a bug? I'm using R2019b and slightly reticent to update just at the mo as I'm half way through a project with a lot of additional package installs. I also don't know why table code that was working three weeks ago has stopped working (mocrosoft update?!).
If anyone could offer help on getting an array of doubles in a table, with renamed varname and then appending text and doubles columns I'd be very grateful.
Thank you. Jac

1 comentario

Your first bit of code works for me. Try clearing your workspace?
results=magic(5);
T1=array2table(results);
T1.Properties.VariableNames = {'a','b','c','d','e'}
T1 = 5x5 table
a b c d e __ __ __ __ __ 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9

Iniciar sesión para comentar.

 Respuesta aceptada

jaclyn
jaclyn el 10 de Feb. de 2021

0 votos

SOLVED...
Terrible hack but I have just copied the \datatypes \bigdata \controllib and comm folder from the laptop it was working on to non-working laptop (zipping the original folders in case it causes issues). It is now working so must have been a bug in those folders.
@Steven Lord, as you are staff, FYI...
Tables could be created but not ammended in anyway on R2019b installed on 11/11/2019, this problem appeared to be fixed in a R2019b version installed on 22/11/2019.
I will update matlab formally once I've finished some analysis in EEGlab.
Thanks to all who replied.
Jac

1 comentario

Cris LaPierre
Cris LaPierre el 10 de Feb. de 2021
Editada: Cris LaPierre el 10 de Feb. de 2021
It is very likely you are using the exact same version of MATLAB in both computers. You can check by running the ver command in the MATLAB command window. If that is the case, the install date does not matter. There may have been an issue with how MATLAB installed on your laptop. You could try reinstalling it. If the same thing happens, there may be an issue with file system on that laptop.

Iniciar sesión para comentar.

Más respuestas (2)

Steven Lord
Steven Lord el 9 de Feb. de 2021

0 votos

Can you show us the full and exact text of the error message you're receiving? Not just the "Too many input arguments" part but everything shown in red and/or orange when you run that code? Knowing not just what error occurs but where it occurs may help us determine the cause of the error.
If I had to guess I'd say you'd written a table.m file that was taking precedence over the table function included in MATLAB, and your table.m accepted fewer inputs than the table function, but that's just an educated guess.

5 comentarios

jaclyn
jaclyn el 10 de Feb. de 2021
Hi, I've rebooted this morning and still having same issue (as per Cris comment, thank you for checking).
results=magic(5)
T1=array2table(results);
T1.Properties.VariableNames = {'a','b','c','d','e'};
Gives
Too many input arguments.
That is the only error I receive. Which is why I'm struggling to work out what is wrong. I'm careful about naming files with functions names. Just double checked and the only instance of table is in ('C:\Program Files\MATLAB\R2019b\toolbox\matlab\datatypes\@table'). I've also just tried adding that path directly, and the above code still doesn't work.
Thank you both.
jaclyn
jaclyn el 10 de Feb. de 2021
Also to note, I can create a table...it's the modification of it that seems to be failing. i.e.
A=magic(5); %works
age=(A(:,1)); %works
T=table(age); %works
T.Properties.VariableNames = {'height'}; %Too many input arguments.
T.age(6)=12; %Too many input arguments.
Try
restoredefaultpath; rehash toolboxcache
and see if that works for you.
If not, then please send us the output of
ls
showing which files are in your current directory, so that we can check for potential conflicts. For example tabularDimensions/setlabels can have problems if you have your own isstring.m
Steven Lord
Steven Lord el 10 de Feb. de 2021
I doubt the message "Too many input arguments" is the entire error message you receive. For instance, if I make a mistake in a call to ode45:
>> ode45(@(t, y) y.', [0, 10], [1; 2])
Error using odearguments (line 93)
@(T,Y)Y.' must return a column vector.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Everything after the first line of that copied text is displayed in red in the Command Window. It points me to specific lines in ode45 and a helper function odearguments. That information will be helpful in determining where the problem actually occurs, which may suggest a next step for diagnosing the cause of the error.
jaclyn
jaclyn el 10 de Feb. de 2021
@Steven Lord it IS the entire message I was receiving....
T.Properties.VariableNames = {'height'};
Too many input arguments.
Absolutely nothing else. I'd send a screen shot but now I've fixed the issue (see accepted answer above) I can't replicate it without unzipping old files etc. I know how to debug - there were no error pointers (which I've never experienced before), hence me getting stuck and posting on forum.
@Walter Roberson - thanks for posting again, as I've rectified this issue I can't try this, but will in future.

Iniciar sesión para comentar.

jaclyn
jaclyn el 10 de Feb. de 2021

0 votos

Hi, it still does not work.
ls *.m (I have a bunch of jpgs in this folder also, nothing else). The simple I sent code/ my script (creategoriallaexcel.m) also doesn't work from any location.
C1_jb.m creategoriallaexcel.m init_gabor_jb.m
canny_calc.m edge_find.m sumfilter.m
create_stim.m fit_circle_through_3_points.m wrapper_script.m
create_stim_blankbark.m hmax_calc.m wrapper_scriptforgorilla.m
the jpgs are all of name format img{i}_2.jpg
[FYI creategoriallaexcel.m just calls functions to create some stimuli jpgs and then save detail from these in an array, which I'm then trying to tabulate, rename columns and then append some numerical/ text columns before saving in the last few lines].
I have just started up my work laptop (also has matlab2019b, but poor memory and I don't have admin rights so not great for working on). However, the simple code I sent does work on this. I've search for table in the entire matlab path and only difference I can see is.
Non working laptop
C:\Program Files\MATLAB\R2019b\toolbox\matlab\datatypes\+matlab\+internal\+coder\@table\table.m
C:\Program Files\MATLAB\R2019b\toolbox\matlab\datatypes\@table\table.m
C:\Program Files\MATLAB\R2019b\toolbox\matlab\bigdata\@tall\table.m
C:\Program Files\MATLAB\R2019b\toolbox\shared\controllib\graphics\+sharedlsimgui\table.m
Working laptop
lines above, plus.
C:\Program Files\MATLAB\R2019b\toolbox\comm\commutilities\@commgui\@table\table.m
I installed both these versions of matba at around the same time, as I tend to update all machines at once when I upgrade to avoid compatibility issues when at work/ home.
Thank you

1 comentario

At the command line, command
dbstop if caught error
A=magic(5); %works
age=(A(:,1)); %works
T=table(age); %works
T.Properties.VariableNames = {'height'};
It should stop at the actual error location; at that point please show us the line it had the problem with, and show us
dbstack
I am expecting that the problem will be near function setlabels in file tabularDimensions

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Etiquetas

Preguntada:

el 9 de Feb. de 2021

Editada:

el 10 de Feb. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by