Problem with changing data in a uitable that was created with Programmatic UI

2 views (last 30 days)
I have an interface that creates a button that displays a table where the user can change some data. But when I try to change the data it shows me an error.
Undefined function or variable 't'.
Error while evaluating uitable CellEditCallback_
Also I created another button where I can save the data changed by the user because i need it for another function but I do not Know where it should be because I need that all the data has been changed and the storage it
The code is
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
f = figure('Name','Estructura red neuronal','NumberTitle','off','Color',[0.4 0 0],'Position', [500 500 300 180],'MenuBar','none','DockControls','off');
% Column names and column format
columnname = {'Capa','Num Neuronas','F Entrenamiento'};
columnformat = {'numeric','numeric',{'Tansig' 'Logsig' 'Hardlim' 'Purelin'}};
% Define the data
d = cell(3,3);
for i=1:3
d(i,1)={i};
d(i,2)={5};
d(i,3)={'Tansig'};
end
% Create the uitable
t = uitable('Position',[20 50 260 100],'Data', d,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', [false true true],...
'RowName',[],'CellEditCallBack',@editTable_Callback);
pb = uicontrol(f,'Style','pushbutton','String','Continuar',...
'Position',[100 10 100 30],'Callback',@pb_Callback);
set(t,'Data',d,'celleditcallback','get(t,''Data'')');
I appreciate your assistance

Accepted Answer

Walter Roberson
Walter Roberson on 8 Jul 2015
When you pass a string as a callback, the string is evaluated in the base workspace, not the workspace of the function that set the string. You should code as
set(t, 'Data', d, 'CellEditCallback', @(src,event) get(src, 'Data');
You might observe that after the data is fetched nothing is done with it. That is the same as what you tried to code: you tried to get() the Data but did nothing with it once you fetched it. I do not know what you were trying to program, but the line I provided above does the same thing you coded.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!