Stuart’s MATLAB Videos

MATLAB: Manipulating the data in a UItable in GUIDE 10

Posted by Doug Hull,

If you have a UItable in a UI made in GUIDE, you might want to change that data in a callback. For instance, you might want to change the values or increase the size of the dataset. This short video shows you the process to get the data into a variable, manipulate it, then set it back into the UItable.

10 CommentsOldest to Newest

Thanks a ton Doug for helping me get started with GUIDE.
I’ve a MATLAB program that detects the skin of the user in real time via webcam. I want this program to run when I click the push button in the GUI designed using GUIDE. How should I go about it?

There is a callback associated with the button. You put the code you want to run in that callback. See the other GUI/GUIDE videos (list to left of blog) to find similar things.

I did watch other GUIDE videos from here, but couldn’t find one that explains to directly enable to run a separate file by clicking the push button. Videos here explain the method to write functions under the callback function. I’m really confused about this part. I hope you rescue me out of this.

hai, i had create the uitable. after key in data in uitable, i would like to reset the data. i create a pushbutton to reset it, but it doesnt work. how i can reset the data in uitable after i click the reset (pushbutton)?

Sorry, I have a problem while I follow your tutorial, the code :
function add_gen_Callback(hObject, eventdata, handles)
% hObject handle to add_gen (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data = get(handles.uitable2,’data’);
data(end+1,:) = 0;
set(handles.uitable2,’data’,data)
And the error display in the command window when run this code :
??? Conversion to cell from double is not possible.

Error in ==> LMP_ver1>add_gen_Callback at 82
data(end+1,:) = 0;

Error in ==> gui_mainfcn at 96
feval(varargin{:});

Error in ==> LMP_ver1 at 42
gui_mainfcn(gui_State, varargin{:});

Error in ==>
@(hObject,eventdata)LMP_ver1(‘add_gen_Callback’,hObject,eventdata,guidata(hObject))

??? Error while evaluating uicontrol Callback
How can I fix it ?
Thank you !!!

It looks like your uitable’s ‘Data’ property is a cell array. Do you initialize the “Data” property somewhere? I’d set a breakpoint at the error line and take a look at the value of the variable data.

Add A Comment

What is 1 + 10?

Preview: hide

These postings are the author's and don't necessarily represent the opinions of MathWorks.