Storing only selected data into table using a pushbutton and a checkbutton in GUI
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have some values A and B. The problem that I have is when I click on Pushbutton to calculate values AA,BB (which will be stored in a nx1 format columnwise) separately or together, I am not sure how to enable/disable them and display in table Results_table properly depending on which one I select.
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); %%convert it to cell in order to put it in a table
data(:,1) = AA; %%I think here lies the problem, but not sure how to solve it
data1=data(:,1); %%I think here lies the problem, but not sure how to solve it
set(handles.Results_table,'Data', data1);
set(handles.Results_table,'ColumnName',{'AA'}); %%define column name
else
end
same goes here:
BB = get(handles.B,'Value');
if BB== 1
%%Perform function. Here I calculate the function BB%%
BB = num2cell(BB);
data(:,2) = BB; %%I think here lies the problem, but not sure how to solve it
data1=data(:,2); %%I think here lies the problem, but not sure how to solve it
set(handles.Results_table,'Data', data1);
set(handles.Results_table,'ColumnName',{'BB'});
else
end
Now, when I press Pushbutton in order to execute these functions (weather they 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 (weather I select either AA, BB or both of them) in table Results_table with appropriate column names.
What am I doing wrong?
Thanks!
2 commentaires
Jan
le 5 Août 2017
I do not understand the problem yet. Which is the handle of the checkbox? What is the contents of handles.A and handles.B? In which function is the posted code found?
Réponse acceptée
Jan
le 5 Août 2017
Modifié(e) : Jan
le 5 Août 2017
With some guessing:
Head = {'A', 'B'};
Data = [num2cell(AA), num2cell(BB)];
Include = ([get(handles.A, 'Value'), get(handles.B, 'Value')] == 1);
set(handles.Results_table, 'Data', Data(:, Include), 'ColumnName', Head(Include));
It is not clear, if handles.A is the checkbox to include/exclude the column, or if it conatins the values. But I hope the idea is clear and you can adjust this to the real problem.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Import and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!