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

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 Exchange에서 App 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