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.

5 views (last 30 days)
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.

Answers (1)

Geoff Hayes
Geoff Hayes on 26 Jul 2014
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 Comments
Geoff Hayes
Geoff Hayes on 28 Jul 2014
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.
matlablearner
matlablearner on 28 Jul 2014
Ok. I am attaching my codes for your reference. The attached code is the initial code where your idea has not been incorporated. Download them and run the gui(Modif.fig) for a clear understanding. While I am typing this, I found out the problem. I am passing the variable called "mark" as a single value instead of array to the function nodelistupdate.So evrytime only the new node is added to the first row. Kindly go through the code so that my function terminologies can be understood.
Thanks a lot for your time..

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!