如何在 GUI、Matlab 中编写对话框?

How to program a dialog box in GUI, Matlab?

我在 Matlab (GUI) 中有一个带有 "Ok" 按钮的对话框。

h = 消息框('Please press Ok to display the image')

然后我使用 imshow 来显示该图像:

imshow('myImage.jpg')

我希望 GUI 等待用户的响应(按 OK)然后显示图像,但现在这两者同时发生。我该如何解决这个问题?

感谢您的帮助

使用uiwait并在imshow之前将消息对话框设置为modal:

uiwait(msgbox('Please press Ok to display the image','Test msg box','modal'));

或:

h = msgbox('Please press Ok to display the image','Test msg box','modal');
uiwait(h);