From: Rajesh on
Hi everyone,
I have a checkbox in my GUI. we know when it is checked the value returned is 1 and when unchecked it returns 0. but if it is left unattended then irrespective of its status the value returned is an empty matrix. How to use/set a default value for a checkbox based on its status.
From: ImageAnalyst on
On Mar 23, 3:40 am, "Rajesh " <rv_acha...(a)rediffmail.com> wrote:
> Hi everyone,
> I have a checkbox in my GUI. we know when it is checked the value returned is 1 and when unchecked it returns 0. but if it is left unattended then irrespective of its status the value returned is an empty matrix. How to use/set a default value for a checkbox based on its status.  

--------------------------------------------------------------------------------
I'm not sure what you mean. A checkbox has to be either checked or
unchecked doesn't it? I'm not aware of any "unattended" state.
Perhaps does that mean you have the checkbox disabled?

And I'm not sure what you mean by "setting or getting a checkbox value
based on its status." Isn't the "status" the same thing as its value
(unless you mean the status to be something else such as the "enable"
or "visible" property)?
From: Rajesh on

hi,
sorry for the delay i am afraid i dint get a notification. anyway.

may be my question was not clear. let me elaborate. I have a checkbox on a GUI. when i run the GUI i see the checkbox unchecked on the interface. Lets call it the default state. Now in the callback function of the box i have written

global var1
var1=get(hObject,'Value');

further, I am using var1 as a condition to skip (if var1==0) or perform (if var1==1) a certain loop in another callback.

Now, if i intend to skip this particular loop i would simply leave the box unchecked but when i do this all i get is an empty matrix for var1 whereas what i want is var1=0 since the box was unchecked.

However, if i check the box and then uncheck it again i get var1=0.

am i missing something here. 'cause if an innocent user wants an unchecked box why would/should he check it first and then uncheck it to get the desired results??

I feel i would be required to read the current status of all such boxes on the UI when i launch it but i dont know how to do it.
hope its clear now.
From: Walter Roberson on
Rajesh wrote:


> I have a checkbox on
> a GUI. when i run the GUI i see the checkbox unchecked on the interface.
> Lets call it the default state.

> Now, if i intend to skip this particular loop i would simply leave the
> box unchecked but when i do this all i get is an empty matrix for var1
> whereas what i want is var1=0 since the box was unchecked.
>
> However, if i check the box and then uncheck it again i get var1=0.

I recall seeing that on an earlier version; I haven't checked to see if
it is still an issue.

The solution for me was simply to explicitly set the Value of the box at
the time the uicontrol was created. As that is better programming
practice anyhow, I just always do that now.
From: Rajesh on

> The solution for me was simply to explicitly set the Value of the box at
> the time the uicontrol was created. As that is better programming
> practice anyhow, I just always do that now.

God, How i wish Mr. Walter roberson could also tell how to set it at the time of creation.
I changed the 'Value' field in the property inspector to 1.0 and the default state changed to 'checked' from previous 'unchecked' but i am afraid my var1 is still an empty matrix.
:(
I am using R2007a btw.
 |  Next  |  Last
Pages: 1 2 3
Prev: power system studies
Next: need help about xcorr