Using a continue button on a plot created within a function

3 ビュー (過去 30 日間)
Roan Kirwin
Roan Kirwin 2020 年 4 月 17 日
コメント済み: Roan Kirwin 2020 年 4 月 17 日
I'm showing a series of plots that are created within a function and would like to continue onto the next plot using a button. However, I cannot figure out how to get the button to resume the code using uiresume.
Here is a simplified version of the code in question:
clear all
close all
clc
plots
function plots()
hFig = figure('Position',[500 500 400 300]);
c = uicontrol('String','Continue','Callback','uiresume(hFig)');
for i = 1:10
uiwait(hFig)
disp('Program execution has resumed');
plot(1:i)
end
end
and the error code:
Error using waitfor
Unrecognized function or variable 'hFig'.
Error using uiwait (line 81)
Error while evaluating UIControl Callback.
Unfortunatly, moving ouside a function is not an option.

採用された回答

Geoff Hayes
Geoff Hayes 2020 年 4 月 17 日
Roan - can you nest your continue button callback function within plots like
function plots()
hFig = figure('Position',[500 500 400 300]);
c = uicontrol('String','Continue','Callback',@OnContinueButtonCallback);
function OnContinueButtonCallback(~,~)
uiresume(hFig);
end
for i = 1:10
uiwait(hFig)
disp('Program execution has resumed');
plot(1:i)
end
end
  1 件のコメント
Roan Kirwin
Roan Kirwin 2020 年 4 月 17 日
This works perfectly, Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatics and Dynamics についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by