フィルターのクリア

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 Center および File ExchangeDialog Boxes についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by