How to add data( in the form of rows) to an existing table in a GUIDE GUI? The user should be able to add data in the consecutive rows of the table.
1 次查看(过去 30 天)
显示 更早的评论
I am using structures wherein geo is a global variable and geo.nodes(1) = nodename,geo.nodes(2)=xcoordinate,geo.nodes(3)=ycoordinate,geo.nodes(4)=zcoordinate,geo.nodes(5)= a checkbox. ( As shown in the picture). I have a separate listbox which had the node name. (Which is nothing but geo.nodes(1)). My objective is: Every time the user should create a node name and then enter the x,y and z coordinates. This coordinate data should be entered in the GUI table and the coressponding point be plotted in a graph.
But the problem I face is every time after i enter a new node name in the listbox,the control comes to the first row of the table. I am not able to simulataneously see all the different nodes and their coordinates information. The nodes are getting plotted but the data is not getting added to the UI table. Since the data is not getting added, only the selected node gets plotted in the graph handle.
I am attaching the code for your reference.
if size(geo.nodes,1) > 0
tabledata = {geo.nodes(mark,2), geo.nodes(mark,3), geo.nodes(mark,4), geo.nodes(mark,5)};
set(handles.nodedatatable,'data',tabledata);
end
Kindly request your support. Thanks In Advance Matlablearner.
0 个评论
回答(1 个)
Geoff Hayes
2014-7-26
If I understand the problem correctly, it seems that only one geo.node is populating the uitable widget at any given time: a new node is added, and is displayed in the table, but any previous entry is no longer there. If that is the case, then it may be because of the code
if size(geo.nodes,1) > 0
tabledata = {geo.nodes(mark,2), geo.nodes(mark,3), geo.nodes(mark,4), geo.nodes(mark,5)};
set(handles.nodedatatable,'data',tabledata);
end
I'm not sure where this code is being called from (button callback?) but a new tabledata cell array is being instantiated with the geo.node data, and is then being written to the uitable without any care as to what was there before. So only one row will ever be shown in this table.
If you want to keep track of what was already there, then you have to concatenate the new row with the previous table data
if size(geo.nodes,1) > 0
tabledata = get(handles.nodedatatable,'data');
rowdata = {geo.nodes(mark,2), geo.nodes(mark,3), geo.nodes(mark,4), geo.nodes(mark,5)};
set(handles.nodedatatable,'data',[tabledata ; rowdata]);
end
With the above, each new row (set of coordinates) is added following all other rows in the table.
Try the above and see what happens!
3 个评论
Geoff Hayes
2014-7-28
What do you mean by a row gets added but with zeros? The above only adds one new row, so how can there be two rows created for every new node?
You will have to supply more code (perhaps as an attachment) to see how you integrated the above into your callback.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!