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

6 Ansichten (letzte 30 Tage)
Mario
Mario am 2 Aug. 2017
Kommentiert: Jan am 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 Kommentare
Mario
Mario am 2 Aug. 2017
A, B and C are my results that I calculated from the previous code I wrote.
So that is what I want to put in a table.
The results are stored in a nx1 format (49x1 that I mentioned is just from testing one set of data).
I used cells as I thought that would be suitable for handling in table. But it is not neccesary if you have a better idea.
Mario
Mario am 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!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Akhilesh Thakur
Akhilesh Thakur am 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 Kommentare
Mario
Mario am 5 Aug. 2017
Thanks you for your answer regarding globals and their callbacks, I appreciate it. But I have another issue now.
When I click on Pushbutton to calculate values AA,BB separately or together, I am not sure how to enable/disable them and display in table Results_table properly.
My following code for this is:
AA = get(handles.A,'Value');
if AA == 1
%%Perform function. Here I calculate the function AA
AA = num2cell(AA);
data(:,1) = AA;
data1=data(:,1);
set(handles.Results_table,'Data', data1);
set(handles.Results_table,'ColumnName',{'AA'});
else
end
BB = get(handles.B,'Value');
if BB== 1
%%Perform function. Here I calculate the function BB%%
BB = num2cell(BB);
data(:,2) = BB;
data1=data(:,2);
set(handles.Results_table,'Data', data1);
set(handles.Results_table,'ColumnName',{'BB'});
else
end
Now, when I press Pushbutton in order to execute this functions (weather thaey are previously checked/unchecked with checkbutton) I am not getting a desired result stored in table Results_table with proper column names.
What I want in the end is depending on which checkbutton I select, after pressing the Pushbutton I want to store and display the selected results in table Results_table with appropriate column names.
What am I doing wrong?
Thanks!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by