waitbar + surf functions. are they incompatible?

2 次查看(过去 30 天)
[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

采纳的回答

Walter Roberson
Walter Roberson 2011-6-21
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 个评论
PN
PN 2011-7-12
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 2011-7-12
h = gca; i suppose. Anyway, thanks for the insight! My problem is solved.

请先登录,再进行评论。

更多回答(2 个)

PN
PN 2011-6-21
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 2011-6-21
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...

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by