フィルターのクリア

How I can check the button if enabled or disabled in MATLAB?

4 ビュー (過去 30 日間)
Eliza
Eliza 2017 年 12 月 7 日
回答済み: Walter Roberson 2017 年 12 月 10 日
I wanna use if condition to check if the button is Enable or Disable can I do that ?

回答 (2 件)

Jan
Jan 2017 年 12 月 7 日
編集済み: Jan 2017 年 12 月 9 日
Actually the question is far too lean to be answered reliably. But a guess:
if handles.Checkbox1.Value
This is sufficient already, when I assume, that handles.Checkbox1 is the handle of your checkbox. Examine the tag of the checkbox or the handles struct to find the real name in your code.
[EDITED] The solution with R2015b and teh property "Enable" is:
if strcmp(handles.Button1.Enable, 'off')
If you handles.msg is a uint8, it is not a valid button handle.
  11 件のコメント
Eliza
Eliza 2017 年 12 月 9 日
Here is the properties of msg
(msg) with properties:
Style: 'pushbutton'
String: 'First'
BackgroundColor: [0.9400 0.9400 0.9400]
Callback: [function_handle]
Value: 1
Position: [55.2000 16.6923 22 2.6923]
Units: 'characters'
BackgroundColor: [0.9400 0.9400 0.9400]
BeingDeleted: 'off'
BusyAction: 'queue'
ButtonDownFcn: ''
CData: []
Callback: [function_handle]
Children: [0x0 handle]
CreateFcn: ''
DeleteFcn: ''
Enable: 'on'
Extent: [0 0 14.8000 1.6154]
FontAngle: 'normal'
FontName: 'MS Sans Serif'
FontSize: 10
FontUnits: 'points'
FontWeight: 'bold'
ForegroundColor: [0 0 0]
HandleVisibility: 'on'
HorizontalAlignment: 'center'
Interruptible: 'on'
KeyPressFcn: ''
KeyReleaseFcn: ''
ListboxTop: 1
Max: 1
Min: 0
Parent: [1x1 Panel]
Position: [55.2000 16.6923 22 2.6923]
SliderStep: [0.0100 0.1000]
String: 'Watermark'
Style: 'pushbutton'
Tag: 'msg'
TooltipString: ''
Type: 'uicontrol'
UIContextMenu: [0x0 GraphicsPlaceholder]
Units: 'characters'
UserData: [1x0 double]
Value: 1
Visible: 'on'
Jan
Jan 2017 年 12 月 10 日
@Eliza: Why do you post the properties? Note, that this is a contradiction to what you have posted before:
class(handles.msg)
ans =
uint8
Please try to find out, why your handles.msg is sometimes an UINT8 and sometimes a graphics handle. Perhaps you overwrite it anywhere? But if it is a graphics handle, my suggestion should work directly. Did you try it?

サインインしてコメントする。


Walter Roberson
Walter Roberson 2017 年 12 月 10 日
At some point in your code, you are overwriting handles.msg with a uint8 array. Search your code for assignments to handles.msg

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by