Storing a multiple data into table GUI using a pushbutton and a checkbutton
Mostrar comentarios más antiguos
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 comentarios
Adam
el 2 de Ag. de 2017
Well, you are telling it to override the previous ones by just setting 'Data' to something different.
Just get the whole 'Data' out of the table, update it (with numeric data if that is what you have) and then set it again.
Mario
el 2 de Ag. de 2017
Adam
el 2 de Ag. de 2017
data = get( handles.Results_table, 'Data' );
data( 2,4 ) = 7;
data( :,3 ) = B;
set( handles.Results_table, 'Data' );
etc
Mario
el 2 de Ag. de 2017
Adam
el 2 de Ag. de 2017
What size is data?
Mario
el 2 de Ag. de 2017
Adam
el 2 de Ag. de 2017
What about the variable you call data though. What size is that? And if your data is numeric then store it in a numeric array and store that as 'Data' in the table. Don't use a cell array if you don't need to.
Mario
el 2 de Ag. de 2017
Mario
el 3 de Ag. de 2017
Respuestas (1)
Akhilesh Thakur
el 3 de Ag. de 2017
0 votos
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 comentarios
Mario
el 5 de Ag. de 2017
Categorías
Más información sobre Historical Contests en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!