the question is : in pushbutton callback i read this code:
C=[h1 h2 h3 h4 h5 h6];
set(handles.uitable1,'DATA',C);
the uitable1 display the result in the first row,
while i will change the value of C, when i push the pushbutton again, how to write C to sceond row?

 采纳的回答

current_data = get(handles.uitable1, 'data');
newdata = [current_data; C];
set(handles.uitable1, 'data', newdata);

12 个评论

thank you ,I read this code ,but when i push the pusbutton ,the uitable show two row .
i want when i fist push the button ,the uitable show the first row,when i second push,the uitable show the data in second row ,and so on ,the first row save the date which not changed.
Jan
Jan 2017-12-11
@ww ww: I do not really understand, what you are asking for. What should appear in the first and second row at the third click?
such as,I have an edit1 ,an uitable1 and a pushbutton1,I write data to edit1,after some caculations,I get the data C and show in frist row of uitable, now,I will write different data to edit1,then I get the different data C,so,I want to show the different data C in sceond row of uitable1,if I change data C again,it will be show in third row.
@Jan Simon: thank you very much,how can i do this?
Jan
Jan 2017-12-11
@ww ww: But this is exactly what Walter's suggestion does.
By the way, I asked: "What should appear in the first and second row at the third click?" As far as I understand, the answer is: "The values create by the first and second click".
ww ww
ww ww 2017-12-11
编辑:ww ww 2017-12-11
@Jan Simon but,it can not work,i took Walter Roberson advice,i mean,when i frist click,uitable show like this
this is my code
C=[h12 q3 pwf2 cy2 glr2 qd]; %one row
set(handles.uitable3,'DATA',C);
current_data = get(handles.uitable3, 'data');
newdata = [current_data; C];
set(handles.uitable3, 'data', newdata);
i mean,i have only one pushbutton,when i frist click,uitable show the first row,when i second click ,the data show in second row ,but,now when i second click, the data covered the first row.
Remove the
set(handles.uitable3,'DATA',C);
@Walher Roberson think you very much ,that is ok!
@Walter Roberson: sorry,I try agian this code ,it is can not work again,if i remove:
set(handles.uitable3,'DATA',C); % code
how can i get data from uitable? this is error
add an pushbutton~that is ok
For this to work the first time, the data property has to have been left initialized to its default [] .
For it to continue to work, the number of columns in C needs to be the same as the number of columns in the existing table.
I suspect some of your calculated h values might be empty, giving you a C shorter than previous rows. Use the debugger to find out.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!