animation turns static in live scripts

I have the following code that works well in m files but not in live scripts because a figure pops up in a separate window and the other figure on the output panel in the live script becomes static. How to revise so that pause, continue and close buttons can control the figure on the output panel in the live script rather than in a separate window?
fig = figure;
pauseButton=uicontrol('Style','pushbutton',...
'String','pause','Position',[20 60 60 20],...
'Callback',@(src,event)uiwait);
continueButton=uicontrol('Style','pushbutton',...
'String','continue','Position',[20 40 60 20],...
'Callback',@(src,event)uiresume);
closeButton=uicontrol('Style','pushbutton',...
'String','close','Position',[20 20 60 20],...
'Callback',@(src,event)close);
for i=1:100
if ~ishandle(fig),break;end
plot(linspace(0,1),i*linspace(0,1))
title(['i=',num2str(i)]);pause(0.1);
end

댓글 수: 4

Zinea
Zinea 2024년 3월 28일
편집: Zinea 2024년 4월 8일
This functionality of interacting with the output panel is not available in MATLAB Live script as of now. The only way is to use buttons on the separate window that pops up when you execute the script.
feynman feynman
feynman feynman 2024년 3월 29일
편집: feynman feynman 2024년 3월 29일
Thank you for the answer and may I ask what you mean by ‘The only way buttons on the separate window that pops up when you execute the script.’? Must I give up using live scripts for these functionalities?
Zinea
Zinea 2024년 4월 8일
You can use the control buttons on the separate window itself to interact with the figure.
feynman feynman
feynman feynman 2024년 4월 12일
But if the figure is in a separate window, it's not in live scripts and one cannot playback the animation?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Animation에 대해 자세히 알아보기

질문:

2024년 2월 28일

댓글:

2024년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by