uicontrolでのCallbackの操作

4 visualizzazioni (ultimi 30 giorni)
Mamoru Mabuchi
Mamoru Mabuchi il 20 Mag 2021
Commentato: Mamoru Mabuchi il 20 Mag 2021
uicontrolを使って、ボタンが押されるまで処理を保留し、ボタンが押されたら処理を再開するスクリプトを作成したいです。
下記のスクリプトを作成してみましたが、思い通りの動作をしません。
どのようにスクリプトを記述すれば良いでしょうか、アドバイスお願いします。
fig = figure(1);
aaa = 0;
button = uicontrol(fig);
button.Callback = @ButttnFunction;
while aaa == 0
end
function ButttnFunction(src,event)
assignin('caller','aaa',1);
end

Risposte (1)

Megumi Fukuda
Megumi Fukuda il 20 Mag 2021
Modificato: Megumi Fukuda il 20 Mag 2021
「思い通りの動作をしません」というのは、figureが出てこない・ボタンを押せないということでしょうか。
whileの中身を以下のように変更してみてください。
while aaa == 0
disp('Button is not pressed yet')
pause(0.1);
end
pause(0.1)でwhileループの繰り返しの間に休みを入れています。ご自身の都合の良い数値に変えてみてください。
なお、GUIDEは将来的に削除される予定です。GUIDEでアプリを作成されている場合、AppDesignerへの移行をおすすめしております。詳細は以下をご覧ください。
GUIDE の移行策
https://jp.mathworks.com/help/matlab/creating_guis/differences-between-app-designer-and-guide.html
  1 Commento
Mamoru Mabuchi
Mamoru Mabuchi il 20 Mag 2021
解決いたしました。
ありがとうございました。

Accedi per commentare.

Prodotti

Community Treasure Hunt

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

Start Hunting!