check box, hey all, im wrote a code for creating a gui that contain checkbox and i cant take the data out of the function when i call it. what should i do?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
this is the code:
function [tests]=gui_exsist_tests()
tmpcyc1=0; tmpcyc2=0; fpoint=0; sts=0; toto=0; linearity=0; noise=0; avar=0;
GUI_checkbox;
tests.tmpcyc1=tmpcyc1;
tests.tmpcyc2=tmpcyc2;
tests.fpoint=fpoint;
tests.sts= sts;
tests.toto=toto;
tests.linearity=linearity;
tests.noise=noise;
tests.avar=avar;
end
and this is the importent part from the GUI_checkbox
function checkbox3_Callback(hObject, eventdata, handles)
if get(hObject, 'Value')== get(hObject, 'Max')
fpoint=1;
else
fpoint=0;
end
assignin('base', 'fpoint', fpoint);
function checkbox4_Callback(hObject, eventdata, handles)
if get(hObject, 'Value')== get(hObject, 'Max')
sts=1;
else
sts=0;
end
assignin('base', 'sts', sts);
function checkbox5_Callback(hObject, eventdata, handles)
if get(hObject, 'Value')== get(hObject, 'Max')
toto=1;
else
toto=0;
end
assignin('base', 'toto', toto);
function checkbox6_Callback(hObject, eventdata, handles)
if get(hObject, 'Value')== get(hObject, 'Max')
linearity=1;
else
linearity=0;
end
assignin('base', 'linearity', linearity);
function checkbox7_Callback(hObject, eventdata, handles)
if get(hObject, 'Value')== get(hObject, 'Max')
noise=1;
else
noise=0;
end
assignin('base', 'noise', noise);
function checkbox8_Callback(hObject, eventdata, handles)
if get(hObject, 'Value')== get(hObject, 'Max')
avar=1;
else
avar=0;
end
assignin('base', 'avar', avar);
function pushbutton9_Callback(hObject, eventdata, handles)
close(gcf);
3 comentarios
Image Analyst
el 17 de Jun. de 2019
Attach your fig file and m file if you're still having a problem.
Respuestas (1)
Geoff Hayes
el 27 de Mayo de 2019
Guni - rather than having your callbacks write data to the base workspace, you can have your GUIDE GUI output a (for example) structure that has fields for each of your checkboxes. Take a look at Advanced: Getting an output from a GUIDE GUI and the attached example. In your main function (that which calls the GUI) you could do something like
function [tests]=gui_exsist_tests()
checkboxData = GUI_checkbox;
tests.fpoint = checkboxData.fpoint;
% etc.
You would need to ensure that the output structure has the fields from each of your checkboxes, and that each field is named correctly.
0 comentarios
Ver también
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!