필터 지우기
필터 지우기

waitbar + surf functions. are they incompatible?

조회 수: 1 (최근 30일)
PN
PN 2011년 6월 21일
[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...
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 6월 21일
The doc shows that the handle is not (always) necessary.

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

카테고리

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