guide push button and checkbox callback

3 visualizaciones (últimos 30 días)
kareem
kareem el 1 de Ag. de 2014
Comentada: Adam el 1 de Ag. de 2014
i have about 40 checkboxes that each have a value, basically when i check them then click the push button, i want the push button to group them in an array (lets say x=[]) then open another m file where i can graph, i will have a plot command like ( z,x)
my checkboxes look like
"" global aa
aa=get(hObject,'Value');
if aa==1
aa=conv_data(:,3);
else
aa==0
end ""
for my push button i have
"" global xx
xx==[aa bb cc ....]
my matlab file ""
i get an error for the first checkbox so in this case aa
  1 comentario
Adam
Adam el 1 de Ag. de 2014
I wouldn't recommend using global variables.
You can get away without using checkbox callbacks at all if you don't need anything to react to them.
Just put all your checkbox handles into an array and in the pushbutton callback call something like
checkBoxValues = get( hCheckboxes, 'Value' );
checkBoxValues = [ checkboxValues{:} ];
to give you a logical array from your checkboxes that you can then apply in whatever way you want to extract your data (I'm not sure I fully understand what your code is doing with the value of each checkbox).
Alternatively direct all your checkboxes to the same callback and use the hObject that comes through the callback to store the value for that checkbox in an array of all the checkbox values.

Iniciar sesión para comentar.

Respuestas (1)

Ben11
Ben11 el 1 de Ag. de 2014
Instead of using multiple if/else statements can you simply populate x directly with the values of the checkboxes:
x = [get(handles.checkbox1,'Value') get(handles.checkbox2,'Value') get(handles.checkbox3,'Value')... get(handles.checkbox40,'Value')];
then you have your 1x40 vector containing either 0 or 1 for each particular checkbox.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by