Error using num2cell Too many input arguments.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using the app designer and one of the callbacks, I receive an error in the code:
Error using num2cell
Too many input arguments.
for this line of code:
data=num2cell(app.AccelSNEditField,app.degEditField,...
app.degEditField_2,app.degEditField_3,app.degEditField_4,app.EditField,app.EditField_2,...
app.EditField_3,app.EditField_4);
I am intending to use the code to display within uitable with the data inputted by the user using the Edit fields. I first used:
value = app.TestDateDatePicker.Value;
Testdate = cellstr(datestr(value));
Then used the following code to create the uitable figure:
ATdata=[Testdate data];
ATdata=uitable(uifigure,'ColumnName',{'Accel S/N'; 'Test date' ;'Accel_0' ;'Accel_90'; 'Accel_180'; 'Accel_270';...
'Temp_0' ;'Temp_90'; 'Temp_180' ;'Temp_270'},'Data',ATdata);
Any suggestions to correct the error?
3 commentaires
Rik
le 8 Juil 2020
I don't understand either your goal or your process. Please try breaking it down into smaller steps: what data do you have, and where do you want to put it?
Réponses (1)
Adam Danz
le 8 Juil 2020
I'm guessing that the edit field all contain either scalar numeric values or row vectors of numeric values. If that's the case, and if you're horizontally concatenating those values, you just need to enclose the values in square brackets [ ].
data=num2cell([...
app.AccelSNEditField,...
app.degEditField,...
app.degEditField_2,...
app.degEditField_3,...
app.degEditField_4,...
app.EditField,...
app.EditField_2,...
app.EditField_3,...
app.EditField_4, ...
]);
This should result in a 1xn cell array of scalar numeric values.
It's not clear what you want to do with those values.
If you have an existing UI table named ATdata and you want to vertically concatenate the data values with the existing values in the table, and if the number of columns in the table matches the number of columns in data,
ATdata.data = [ATdata.data; data];
If you're trying to horizontally concatenate the values,
ATdata.data = [ATdata.data, data];
6 commentaires
Adam Danz
le 8 Juil 2020
Modifié(e) : Adam Danz
le 13 Juil 2020
"The Edit Fields are determined by whatever the user inputs, so they may vary with different users."
So, there's no restrictions whatsoever? Any of the following inputs would be accepted?
- 10
- 1 2 3
- abc def
- p98q4ur;adkfj
- (empty)
- 10:20
- "10:20"
If so, that's poor design. You should include feedback in your code that tells the user what types of values are acceped and then clears unacceptable values.
If you do want a table of mixed values, the table needs to be a cell array.
I still have no idea what the table and the inputs should be. I can't provide additional suggestions without some examples.
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!