write data to uitable
显示 更早的评论
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.
@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?
@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".
@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 中查找有关 MATLAB 的更多信息
标签
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)