문제

I need a checkbox to be checked by default on creation of the gui. How can this be done in MATLAB? I looked through the uicontrol inspector without any luck.

도움이 되었습니까?

해결책

You can also set it in the opening function (or on another callback) by inserting the following line:

set(handles.checkbox1,'Value',1);

or replace 'checkbox1' with whatever tag you have assigned to your checkbox. To uncheck, simply set the value to zero. This way, if you have two mutually exclusive options, when you select one you can automatically deselect the other:

다른 팁

I found it. I leave this answer up. Just set "value" in the inspector to "1". It can be found at the very bottom of the uicontrol inspector. Why is it that when I just asked a question, I find the answer myself?

You can set the state of the checkbox on creation with 'Value' the property:

uicontrol(..., 'Value', 1);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top