Storing a multiple data into table GUI using a pushbutton and a checkbutton

2 views (last 30 days)
Mario
Mario on 2 Aug 2017
Commented: Jan on 5 Aug 2017
Hello,
I am developing a GUI in MATLAB using GUIDE and I have some pre calculated numeric values A, B and C (there are more) which I converted to cells using num2cell in order to store them in a table.
Now I want to store these calculated values in a table (in columns AA, BB and CC) in a table named Table_results by clicking on a Pushbutton with previously checked/unchecked checkbutton (this is to check wheather to use or not to use these pre calculated data).
I am struggling with how to put them all in a table, since only the last dataset C is stored in a table Table_results:
I tried something like this which, if I use them one at a time, gives me the value (AA, BB or CC) stored in a Table_results.
But when I use this code below, the last value CC is overriding the previous two:
set(handles.Results_table, 'Data', A);
set(handles.Results_table, 'Data', B);
set(handles.Results_table, 'Data', C);
set(handles.Results_table,'ColumnName',{'AA'}) %%this is in order to name my columns AA, BB and CC
set(handles.Results_table,'ColumnName',{'BB'})
set(handles.Results_table,'ColumnName',{'CC'})
I have more data to implement in this same manner, so in the end I am looking to write a code that enables me to store only the data i selected in checkbutton and display them in a Table results table when I click on a Pushbutton.
Any help would be greatly appreciated.
Thanks in advance!
  9 Comments
Mario
Mario on 3 Aug 2017
I managed to make it work. The problem was to move the functions that I made above the problematic code and after joining the data together + removing this line of code:
data = get( handles.Results_table, 'Data' );
I was able to get it to work.
Thanks for your help!

Sign in to comment.

Answers (1)

Akhilesh Thakur
Akhilesh Thakur on 3 Aug 2017
When you are using set(handles.Results_table,'ColumnName',{'CC'}) its storing any data in the same address that is handles.Results_table. You can use setappdata and getappdata. By this you can share data to different GUI's and it is pretty powerful. If you want to make your data global use setappdata(0,..... ) . Always store with different names. If you are using same name and same address it's going to overwrite your previous data. That's how set and get works. Hope this helps.
  2 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by