MATLAB: Matlab GUI Excel Table

appdesigneredit fieldexcel tableguiMATLAB

properties (Access = private)
t % Table to share between callback functions
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: ExcelDataButton
function ExcelDataButtonPushed(app, event)
app.t = readtable("Book1.xlsx","Sheet",1);
app.UITable.Data = app.t;
%t.Properties.VariableNames{1} = 'Parameter';
%t.Properties.VariableNames{2} = 'Values';
%app.UITable.ColumnName = t.Properties.VariableNames;
end
% Button pushed function: AddButton
function AddButtonPushed(app, event)
Parameter = app.ParameterEditField.Value;
Values = app.ValuesEditField;
nr = {Parameter Values};
app.UITable.Data = [app.t;nr]; //% Line with error is here
end
end
I get an error on the "Line with error is here" that reads:
An error occurred when concatenating the table variable 'Values' using VERTCAT.
Caused by:
Error using matlab.ui.control.NumericEditField/vertcat
Cannot convert double value 1 to a handle
I'm not sure how to solve this yet.
Additionally, I want to find a good way to edit existing data in excel fields.

Best Answer

I'm not quite sure how statename works, but I haven't tried this yet, but I think I need to do this:
statename = "UserData"; %Set statename = to the current values?
statevalue = ValuesEditField; %Then set the statevalue equal to my edit field? (so I need to add a callback function for this edit field?)
table3 = table(statename, statevalue) %
I think:
My user data are the column names
table3 is a new variable name
statevalue is equal to the edit field
and I'm not sure what statevalue represents,
I tried again with and without adding a callback function for the edit field related to adding data to the excel table.
I'm really not sure what I'm doing wrong yet.