close figure: return value
5 次查看(过去 30 天)
显示 更早的评论
HI, i want to know when i figure is close
(here an example no sense)
clear all
f = figure;
for c=1:100
%%do something
c
end
if c
close(f);
end
if f is close
%do something
end
0 个评论
回答(2 个)
dpb
2023-6-23
编辑:dpb
2023-6-23
vv=figure(); %%it's an example but i used countodown timer
What for? and without knowing what that was set for and what its callback is, nothing can say about what effect, if any it may be having.
But, timers are asynchronous as the reference article explains, the rest of the code goes on until the event is triggered.
I'd venture a guess the timer isn't needed here; what you're needing is simply a delay between the close function before the code proceeds to display the table...
function startupFcn(app, setting)
DURATION = 0.5; % DELAY (sec) before subsequent code executes
hF=figure();
% do whatever here w/ figure, data
ls=...; % fill the array
T = cell2table(ls);
close(hF);
START_TIME = tic(); % start delay
while toc(START_TIME)<DURATION, end % spin in place DURATION sec
app.UITable.Data=T; % and then display the table component
end
You'll have to empirically determine how long the delay needs be...to use a timer, the callback for it would have to be the line that displays the table
17 个评论
dpb
2023-6-25
I thought you said it was taking 10 sec or longer to read with your looping code; that's why you were in the morass of trying to add homegrown progress bars, having timing issues and graphics display problems????
I was/am recommending you should take the above code and put it into a callable function and replace the looping structure with it and see if that isn't fast enough you can get rid of all the rest and get on to the rest of the problem.
As another alternative on how to show the user something is happening, I have a couple apps that take a while that otherwise user can't tell anything is happening -- instead of a progress bar with an unknown time, I simply create a text box and every so often when a piece of code finishes and starts the next operation, it writes a "Processing This Part..." message...that updates every so often, just enough to let the user know that the code is alive and well...here you could put it in between each of the variables; but I'm guessing it's fast-enough now that it would just flicker on the screen.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!