フィルターのクリア

Get button answer (Uicontrolled)

2 ビュー (過去 30 日間)
Rafi egal
Rafi egal 2017 年 4 月 6 日
コメント済み: Rafi egal 2017 年 4 月 6 日
Hi everyone, I am stuck with a UIcontrolled button: I would like to have a while loop to stop after I press stop. My current code looks somewhat like this:
n = 15;
i = 1;
figure
tbn1 = uicontrol('Style', 'togglebutton', 'String', 'Stop','Min',0,'Max',1,...
'Position', [20 20 40 20]);
while i < 100
A = struct('value',[]);
A(1).value = magic(n);
step = linspace(1,n,n);
surf(step,step,A(1).value)
title(i);
pause(0.02)
set(tbn1,'Callback',@fun1);
drawnow;
i = i+1;
if tbn1 == 1
break;
end
if tbn1 == 0
continue;
end
end
function fun1(hObject,eventData)
button_state = get(hObject,'Value');
end
thank you for your help!

採用された回答

Jan
Jan 2017 年 4 月 6 日
編集済み: Jan 2017 年 4 月 6 日
n = 15;
i = 1;
figure
tbn1 = uicontrol('Style', 'togglebutton', 'String', 'Stop','Min',0,'Max',1,...
'Position', [20 20 40 20]);
while i < 100
A.value = magic(n);
step = linspace(1,n,n);
surf(step, step, A.value);
title(i);
pause(0.02); % Is drawnow implicitely
i = i + 1;
if get(tbn1, 'Value') == 1 % Or in modern Matlab versions: tbn1.Value == 1
break;
end
end
  1 件のコメント
Rafi egal
Rafi egal 2017 年 4 月 6 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by