Я бы хотел немного добавить к ответу Яира.Во всех GUI, над которыми я работал, я обычно тоже хочу остановить выполнение кода.Используя только модальную опцию, код не останавливается.Ниже приведен краткий пример использования uiwait и модальных параметров Yair (и его ссылки).
Обратите внимание, что если вы пытаетесь отключить только одну фигуру и продолжить выполнение кода, ссылка Yair может бытьВаш лучший вариант.
Надеюсь, это поможет!
%% UIWait Example
clc
fig1 = figure('Name', 'fig1 - UIWAIT');
fig2 = figure('Name', 'fig2 - UIWAIT');
% Wait for figure 2 to close
disp('Note that the script execution halts, but other Matlab windows are still active')
uiwait(fig2)
disp('Script Execution continues on!')
disp('Figure 2 Closed!')
close(fig1);
disp('Figure 1 Closed')
%% Modal Example with uiwait
clc
fig1 = figure('Name', 'fig1');
disp('Note that the script execution halts, and All Matlab windows are blocked')
fig2 = figure('Name', 'fig2 - MODAL','WindowStyle', 'modal');
% Wait for figure 2 to close
uiwait(fig2)
disp('Figure 2 Closed!')
disp('Script Execution continues on!')
close(fig1);
disp('Figure 1 Closed')
%% Modal Example
clc
fig1 = figure('Name', 'fig1');
disp('Note that the script execution does not halt, and All Matlab windows are blocked')
fig2 = figure('Name', 'fig2 - MODAL','WindowStyle', 'modal');
% Wait for figure 2 to close
disp('Script Execution continues on!')
close(fig1);
disp('Figure 1 Closed')