waitbar + surf functions. are they incompatible?

2 Ansichten (letzte 30 Tage)
PN
PN am 21 Jun. 2011
[EDIT: 20110621 14:54 CDT - reformat - WDR]
When trying to establish a waitbar for a double-cycle I am using, I have found out that it is not possible to run it simultaneously with the surf function.
Example:
aux = 0;
steps = length(stelement)*length(csplate);
progressbar = waitbar(0,'graphic under construction...');
for el = 1:length(stelement)
for pl = 1:length(csplate)
aux = aux + 1;
waitbar(aux/steps);
[xplot,yplot,zplot,plotSxx] = stressplot(pl,el);
surf(xplot,yplot,zplot,plotSxx);
hold on;
end
end
close(progressbar)
Question is whether it is possible to overcome this problem in any other way.
Thanks,
PN

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Jun. 2011
Please describe what you see (we don't have your data or your function.)
I have used waitbar in connection with surf without difficulty.
Have you tried
waitbar(aux/steps, progressbar);
to be sure of updating the correct bar?
  3 Kommentare
PN
PN am 12 Jul. 2011
Ok this makes some sense... I have been able to overcome the problem provided that before I use the surf functions, the correct axes are recalled.
So my question then becomes: suppose that said axis are incluided in a gui, and I use the following instruction when I push a random button:
axes(handles.structplot1);
cla(handles.structplot1,'reset');
and then:
for el = 1:length(stelement)
for pl = 1:length(csplate)
step = step + 1;
waitbar(step/steps,progressbar);
[xplot,yplot,zplot,plotSxx] = Oplot(readmodes,pl,el,'Sxx');
axes(handles.structplot1);
surf(xplot,yplot,zplot,plotSxx);
hold(structplot1,'on')
end
end
This is obviously not yet what I want. What exactly do I need to do in order to obtain the axesHandle and how do I use it with surf and hold on instructions? I am obviously missing something here...
PN
PN am 12 Jul. 2011
h = gca; i suppose. Anyway, thanks for the insight! My problem is solved.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

PN
PN am 21 Jun. 2011
by the way, in the previous code, the matlab returns the following error:
Error using ==> uiwaitbar at 101
Couldn't find waitbar handles.
PN

Matt Fig
Matt Fig am 21 Jun. 2011
From the help for WAITBAR (always a good place to look with any funciton!), we have this:
h = waitbar(0,'Please wait...'); % Create a waitbar.
then later:
for i=1:1000,
% computation here %
waitbar(i/1000,h) % Update the existing waitbar.
end
So you see, your update to the waitbar expects the handle returned from when you first invoked it - before the loop...
  1 Kommentar
Walter Roberson
Walter Roberson am 21 Jun. 2011
The doc shows that the handle is not (always) necessary.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by