필터 지우기
필터 지우기

how to add data to a gui table

조회 수: 6 (최근 30일)
Zine
Zine 2013년 7월 27일
I have created a GUI with uitable of (6000,7), I loaded data to my gui through a dropdown menu callback, and I created a push button so if I push it it will show the data on the table, I used the following:
% --- Executes on button press in datatablerefresh. function datatablerefresh_Callback(hObject, eventdata, handles) % hObject handle to datatablerefresh (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.maintable,'data',data);
but I get the error
Undefined function or variable 'data'.
Error in HebalOptics>datatablerefresh_Callback (line 266) set(handles.maintable,'data',data);
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in HebalOptics (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)HebalOptics('datatablerefresh_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
but when I copy the same command to the call back which loads data it is working fine so what is the problem?
note: my data will be loaded and shown on table, then manupulated and shown again on the same table (table will be updated).

채택된 답변

Dishant Arora
Dishant Arora 2013년 7월 27일
편집: Dishant Arora 2013년 7월 27일
scope of data is local to the function is defined in.It can't be used outside that function. If you still want to access it in another function you can use 'setappdata' and 'getappdata' to store data in gui.
setappdata(gcf, 'data', dataName); % stores data in current gui
% mention this in callback which loads data ,
% once you have loaded the data in dataName
data = getappdata(gcf , 'data'); % retrieves data from current gui, to be
% mentioned in keypress function
  댓글 수: 1
Zine
Zine 2013년 7월 27일
thanks a lot Dishant it is exactelly wat I wanted to do

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by