Updating values on UITABLE

Can Someone please give me baby steps on how would I go on doing this?
here is my code
After input of new values on tables, nothing happens to the variable it staid as
0 0 0 0
0 0 0 0
prompt=('How many Elements?=');
elements=input(prompt);
prompt=('How many Nodes?=');
nodes=input(prompt);
Xi=zeros(nodes,1);
Yi=zeros(nodes,1);
Ux_BC=zeros(nodes,1);
Vy_BC=zeros(nodes,1);
clc
f = figure('Position', [100 100 752 350]);
t = uitable('Parent', f, 'Position', [25 25 700 200]);
nodeinfo=[Xi,Yi,Ux_BC,Vy_BC];
set(t, 'Data', nodeinfo);
set(t, 'ColumnName', {'Xi', 'Yi', 'Ux_BC', 'Vy_BC'});
set(t, 'ColumnEditable', [true true true true]);
set(t, 'ColumnFormat', {[] [] {'0' '1'} {'0' '1'}});

Answers (2)

Image Analyst
Image Analyst on 8 Sep 2013
Well you're sending an array of all zeros, so I don't know why you expect anything other than all zeros. What do you think it should be? By chance do you want boolean/logical checkboxes instead of a 0 or 1 dropdown?

3 Comments

Yes I initialize an array with zeros but I try to input new values on the table and they dont get updated on the array I just dont know what to do with CellEditCallback no idea where it goes, or the syntax or if it should be a function or how to type it. that's where I need help, with the callback no, 0 and 1 drop down menu is what I want there thank you
I didn't see any code where you tried to send in new values, just the code where you initialized it with all zeros.
Are you using GUIDE? Just double click on the table to bring up the property inspector and tell it you want to look at that particular callback. Then put whatever code you want in there. That is only if you need to do something immediately as soon as they change something. Otherwise you can retrieve the whole table later, for example in a pushbutton callback, and do something with it there. If you're not using guide then you'll have to figure out how to add a callback with the uicontrol() function. Good luck.
Does your callback actually get executed? When you set a breakpoint inside it, did it stop there?

Sign in to comment.

raul
raul on 8 Sep 2013
Edited: raul on 8 Sep 2013
here is where I stand now I made a function with this parameters function cellupdate(o) tableData = get(o, 'data');
now the last line of my main code I wrote set(t, 'CellEditCallback', @cellupdate);
this still doesn't work what am I missing?

1 Comment

Your function needs to set nodeinfo = get(o,'data'). You're creating a new matrix called tableData. If you want your function to be generic enough to work for any uitable, you need to make it:
function tableData = cellupdate(o)
tableData = get(o,'data');
end

Sign in to comment.

Categories

Find more on App Building in Help Center and File Exchange

Products

Asked:

on 8 Sep 2013

Community Treasure Hunt

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

Start Hunting!