Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

MATLAB: Manipulating the data in a UItable in GUIDE 13

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.

13 CommentsOldest to Newest

Darshan Gajara replied on : 1 of 13

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?

Doug replied on : 2 of 13

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.

Darshan Gajara replied on : 3 of 13

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.

Nic Neogh replied on : 8 of 13

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)?

vetero replied on : 9 of 13

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;
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

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

Error in ==>

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

Stuart McGarrity replied on : 10 of 13

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.

Christian Taylor replied on : 11 of 13

Hello Doug, I have followed the steps in the video nearly exactly, however i am getting the error message:>@(hObject,eventdata)sudoku2(‘pushbutton1_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

Any idea why this might be? Thanks, Christian.

stuartmcgarrity replied on : 12 of 13

Hi Christian , There should be more of an error message there. Try setting the debugger to stop on error. Look at the full error and examine the variables it is referring to.

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide