필터 지우기
필터 지우기

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.

답변 (1개)

Geoff Hayes
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
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.
matlablearner
matlablearner 2014년 7월 28일
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..

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by