Issue with table functions

6 Ansichten (letzte 30 Tage)
jaclyn
jaclyn am 9 Feb. 2021
Bearbeitet: Cris LaPierre am 10 Feb. 2021
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 Kommentar
Cris LaPierre
Cris LaPierre am 9 Feb. 2021
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

jaclyn
jaclyn am 10 Feb. 2021
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 Kommentar
Cris LaPierre
Cris LaPierre am 10 Feb. 2021
Bearbeitet: Cris LaPierre am 10 Feb. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Steven Lord
Steven Lord am 9 Feb. 2021
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 Kommentare
Steven Lord
Steven Lord am 10 Feb. 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 am 10 Feb. 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.

Melden Sie sich an, um zu kommentieren.


jaclyn
jaclyn am 10 Feb. 2021
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 Kommentar
Walter Roberson
Walter Roberson am 10 Feb. 2021
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by