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'}});

回答 (2 件)

Image Analyst
Image Analyst 2013 年 9 月 8 日

0 投票

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 件のコメント

raul
raul 2013 年 9 月 8 日
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
Image Analyst
Image Analyst 2013 年 9 月 8 日
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.
Image Analyst
Image Analyst 2013 年 9 月 8 日
Does your callback actually get executed? When you set a breakpoint inside it, did it stop there?

サインインしてコメントする。

raul
raul 2013 年 9 月 8 日
編集済み: raul 2013 年 9 月 8 日

0 投票

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 件のコメント

Jeremy
Jeremy 2013 年 9 月 8 日
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

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

製品

質問済み:

2013 年 9 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by