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 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Geoff Hayes
2019 年 5 月 27 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!