Borrar filtros
Borrar filtros

Runing a .m file accordıng to the status of checkbox

1 visualización (últimos 30 días)
Atas Fet
Atas Fet el 11 de Mayo de 2015
Editada: Walter Roberson el 13 de Mayo de 2015
hi all,
i have a litlle problem with checkbox status. For example i have a checkbox and pushbutton at GUİ when status of checkbox is unchecked i want to run A.m file otherwise i want to run B.m file. How can be done with easiest way ?
appriciate to your help

Respuesta aceptada

Walter Roberson
Walter Roberson el 11 de Mayo de 2015
function yourcallback(src, event)
state = get(src, 'Value');
if state == 0
run('A.m');
else
run('B.m');
end
end
  3 comentarios
Walter Roberson
Walter Roberson el 12 de Mayo de 2015
Change
state = get(src, 'Value')
to refer to the handle for the checkbox instead of src. The method of finding the appropriate handle will depend upon how you constructed your GUI.
Atas Fet
Atas Fet el 12 de Mayo de 2015
Editada: Walter Roberson el 13 de Mayo de 2015
hii,
i am insistently getting an error: undefined function or variable "state" but when i define state for push button then it forgets totally about the "state" in checkbox how to handle it ?
my code;
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
state = get(hObject, 'Value');
if state1 == 0
display('unchecked');
else
display('checked');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if uicontrol(state, 'Value', 1);
run(A.m);
else
run(B.m);
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre DSP Algorithm Acceleration 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