function pushbutton​1_Callback​(hObject, eventdata, handles)

function pushbutton1_Callback(hObject, eventdata, handles)
handles.metricdata.a=1;
function pushbutton2_Callback(hObject, eventdata, handles)
b=handles.metricdata.a;
if(b~=1)
msgbox('ok');
end
if(b==1)
msgbox('false');
end
in above code, if i don't press pushbutton1 and i press pushbutton2 then message 'ok' should display and if i press pushbutton1 and i press pushbutton2 then message 'false' should display.

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 3 日
編集済み: Azzi Abdelmalek 2013 年 3 月 3 日

0 投票

In function pushbutton1_Callback you should update your handles
handles.metricdata.a=1;
guidata(hObject,handles)

5 件のコメント

vipul utsav
vipul utsav 2013 年 3 月 3 日
it is right for pushbutton1 pressed,and 'false' display but wrong for pushbutton1 is not pressed and nothing display in place of 'ok'
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 3 日
You did not Answer my question, have you updated your handles with guidata, also, have you initialized handles.metricdata.a in your opening function?
vipul utsav
vipul utsav 2013 年 3 月 3 日
編集済み: vipul utsav 2013 年 3 月 3 日
yes,i update data using guidata. and i initialize 'handles.metricdata.a=0'
but problem is there is that every times 'b' become '1',but i want b is different for pushbutton1 is pressed and not pressed
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 3 日
編集済み: Azzi Abdelmalek 2013 年 3 月 3 日
In your yourfilename_OpeningFcn
handles.metricdata.a=0;
guidata(hObject,handles)
In
function pushbutton1_Callback(hObject, eventdata, handles)
handles.metricdata.a=1;
guidata(hObject,handles)
In
function pushbutton2_Callback(hObject, eventdata, handles)
b=handles.metricdata.a;
if(b~=1)
msgbox('ok');
end
if(b==1)
msgbox('false');
end
vipul utsav
vipul utsav 2013 年 3 月 3 日
thanks

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by