Borrar filtros
Borrar filtros

close figure: return value

5 visualizaciones (últimos 30 días)
piero
piero el 22 de Jun. de 2023
Editada: piero el 25 de Jun. de 2023
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

Respuestas (2)

dpb
dpb el 22 de Jun. de 2023
Editada: dpb el 23 de Jun. de 2023
Use isvalid
hF=figure;
isvalid(hF)
ans = logical
1
delete(hF)
isvalid(hF)
ans = logical
0
exist('hF','var')
ans = 1
clear hF
exist('hF','var')
ans = 0
Or, put the reference to the figure inside a try...catch...end structure.
  1 comentario
piero
piero el 23 de Jun. de 2023
Editada: piero el 23 de Jun. de 2023
txk but i don't resolve my problem...
i write a piece of code:
function T=CaricaListaStrategie_Struct2(Sis)
for i=1:length(Sis)
if i==1
vv=figure(); %%it's an example but i used countodown timer
end
%% filled the array
end
close(vv);
T = cell2table(ls );
end
end
function startupFcn(app, setting)
T=CaricaListaStrategie_Struct2(setting);
app.UITable.Data=T;
end;
I want to draw the figure 'vv' but when I close it I want it to create table T (app.UITable.Data=T) Instead I see that while figure "F" is closing, it creates the table for me (not after but during)
i read this post:
but i don't know how can apply it in app designer

Iniciar sesión para comentar.


dpb
dpb el 23 de Jun. de 2023
Editada: dpb el 23 de Jun. de 2023
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 comentarios
dpb
dpb el 25 de Jun. de 2023
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.
piero
piero el 25 de Jun. de 2023
Editada: piero el 25 de Jun. de 2023
the code where I actually asked for help (I did it some time ago and I didn't remember that what takes time is reading the .txt file)(%[~,Sis]=CaricoSistemi2_Struct(Settings);) I put the counter inside this and fix it. The counter is used in the record reading phase, not in processing which is fast.
I apologize for the confusion I made
Anyway, now the problem is solved thanks

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by