uicontrolでのCallbackの操作

5 visualizaciones (últimos 30 días)
Mamoru Mabuchi
Mamoru Mabuchi el 20 de Mayo de 2021
Comentada: Mamoru Mabuchi el 20 de Mayo de 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

Respuestas (1)

Megumi Fukuda
Megumi Fukuda el 20 de Mayo de 2021
Editada: Megumi Fukuda el 20 de Mayo de 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 comentario
Mamoru Mabuchi
Mamoru Mabuchi el 20 de Mayo de 2021
解決いたしました。
ありがとうございました。

Iniciar sesión para comentar.

Categorías

Más información sobre GUIDE アプリの移行 en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!